1👍
✅
These are specified in the UserManager
[Django-doc], you thus should inherit from the UserManager
instead of a simple Manager
:
from django.contrib.auth.models import UserManager
class CustomeUserManager(UserManager):
def get_active_users(self):
return CustomUser.objects.filter(
is_active=True
)
I would strongly advise not to return a list but a QuerySet
for your get_active_users
. A QuerySet
can be filtered further and thus will not make a database query that then later should be post-processed at the Django/Python layer.
Source:stackexchange.com