-
Notifications
You must be signed in to change notification settings - Fork 1
/
managers.py
26 lines (16 loc) · 857 Bytes
/
managers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from django.db import models
from .querysets import CarQuerySet, CarUserQuerySet, EngineQuerySet
class EngineManager(models.Manager.from_queryset(EngineQuerySet)):
pass
class CarManager(models.Manager.from_queryset(CarQuerySet)):
pass
#https://stackoverflow.com/questions/37764070/django-migrations-valueerror-could-not-find-manager-in-django-db-models-manager
class CarUserManager(models.Manager.from_queryset(CarUserQuerySet)):
#https://docs.djangoproject.com/en/3.2/topics/migrations/#model-managers
use_in_migrations = True
class CarUserSuperUserManager(CarUserManager):
def get_queryset(self):
return super().get_queryset().user__is_superuser(True)
class CarUserExcludeSuperUserManager(CarUserManager):
def get_queryset(self):
return super().get_queryset().user__is_superuser(False)