Questions tagged [django-custom-manager]

django-custom-manager refers to an ability to customize Django's default database Manager - an interface through which database query operations are provided to Django models

django-custom-manager refers to an ability to customize Django's default database Manager - an interface through which database query operations are provided to Django models.

See documentation.

43 questions
0
votes
1 answer

UserModel.objects,get(email=email) returns none

I am trying to write a custom UserModel and Email Authentication backend. When I tried to override authenticate method. user=UserModel.objects.get(email=email) returned none. Here are my models.py , authenticate.py, views.py,settings.py models.py…
0
votes
2 answers

Django Custom Manager

I'm looking at some code and I'm curious whether this is good practice. class ToDoManager(models.Manager): def scheduled(self): """ Returns QuerySet of all things to be done. """ return…
Ben
  • 15,010
  • 11
  • 58
  • 90
0
votes
2 answers

creating a custom user model in django using AbstractBaseUser

I am trying to create a custom user model, when i run python manage.py createsuperuser it promote to enter the username, then password, and confirm password, when i hit enter after that i get this error django.db.utils.IntegrityError: UNIQUE…
0
votes
2 answers

when I create super user for custom user model, its dont provide me username, firstname, lastname filed then its show error

when I create super user for custom user model, its dont provide me username, firstname, lastname filed then its show this error: MyAccountManager.create_superuser() missing 3 required positional arguments: 'first_name', 'last_name', and…
0
votes
1 answer

Django: How to filter model property in views

Please how can I filter a queryset in views using model @property method. class TransactionData(models.Model): Nozzle_address = models.CharField(max_length=255) Device = models.ForeignKey(Devices, on_delete=models.CASCADE) Site =…
ray
  • 95
  • 2
  • 14
0
votes
1 answer

How to Implement this custom model manager in django?

am new to Django and I getting some difficulties and I'm confused about the correct way to use Django custom model managers: charities/models.py: from django.db import models from accounts.models import User class Benefactor(models.Model): …
Amir Abbas
  • 28
  • 5
0
votes
0 answers

django.db.utils.IntegrityError: UNIQUE constraint failed: authentication_user.email

I am trying create user through an API, But i am struck on above error. Below are the code of the User and its manager. Here, I am creating custom user model. class UserManager(BaseUserManager): def create_user(self,username,email,…
0
votes
0 answers

Django3/DRF: Custom Queryset __init__() gets called multiple times. [ Chaining Querysets is applied ]

Greeting there ! i have built a custom queryset and i have noticed that its __init__() method gets called multiple times. let's take into consideration that i am also applyingQueryset Chaining models.py class Todo(...): ... objects =…
0
votes
2 answers

Custom Default manytomany manager with a parameter

Following model allows me to handle translations in the database without adjusting code in order to add a language. class NameString(models.Model) en = models.CharField(max_length=55) de = models.CharField(max_length=55) Example use in…
0
votes
2 answers

Django custom user error

I have a custom user model that extends an AbstractBaseUser, as well as my own user manager (GenericUserManager): class GenericUserManager(BaseUserManager): def create_user(self, username, email, password, key_expires): if not email: …
0
votes
1 answer

Django FK using Custom Manager

I have a departmental structure, where reports belong to a subset of Departments. In this case, a Department can be a county, and a report has an FK to a county. class Report(models.Model): user = models.ForeignKey(User) value =…
Rob L
  • 3,634
  • 2
  • 19
  • 38
0
votes
1 answer

Django custom manager - how to use custom manager before QuerySet

I am building my own custom manager to get translations of a model. The Idea is: main model: class BlogTranslationManager(models.Manager): def language(self): lang = translation.get_language() return…
doniyor
  • 36,596
  • 57
  • 175
  • 260
0
votes
1 answer

Django: Custom function value not showing

Trying to understand how to make custom functions in Django. I have the following: models: class OptionManager(models.Manager): def test(self): test = "test" return test class Option(models.Model): value =…
thedeepfield
  • 6,138
  • 25
  • 72
  • 107
1 2
3