SOITA/users/managers.py

22 lines
522 B
Python
Raw Normal View History

2021-12-05 15:23:29 +01:00
from django.contrib.auth.base_user import BaseUserManager
from .querysets import UserQuerySet
class UserManager(BaseUserManager):
def get_queryset(self):
2021-12-05 15:50:15 +01:00
return UserQuerySet(self.model, using=self._db)
def create(self, email, password=None, **kwargs):
if password is None:
message = "User must have valid password"
raise ValueError(message)
user = self.model(email=email, **kwargs)
user.set_password(password)
user.save()
return user