skip to Main Content

Html – Unable to create custom user in django

Here is my models.py file from django.db import models from django.utils import timezone from django.contrib.auth.models import UserManager,AbstractBaseUser,PermissionsMixin # Create your models here. class CustomUserManager(UserManager): def _create_user (self, email,password, **extra_fields): if not email: raise ValueError('Please provide a valid email') email= self.normalize_email(email)…

VIEW QUESTION

Mysql – Slow performance when order by field in foreign key

When a queryset is sorted by a field in a related model performance decreases drastically. I use mysql. For example, I have two models: class Event(models.Model): idEvent = models.BigAutoField(primary_key=True) created_at = models.DateTimeField(db_index=True, verbose_name=_('date')) processed_at = models.DateTimeField(auto_now_add=True, verbose_name=_('processed')) data = models.TextField()…

VIEW QUESTION

Postgresql – How to annotate django queryest using subquery where that subquery returns list of ids from related model records

I have one database model, let's say ModelA: class ModelA(models.Model): field_1 = models.ManyToManyField( "core.ModelB", blank=True ) user = models.ForeignKey("core.User", on_delete=models.CASCADE) type = models.CharField(choices=ModelATypes.choices) The field_1 of ModelA is a many to many field that references ModelB. class ModelB(models.Model): uid =…

VIEW QUESTION
Back To Top
Search