diff --git a/users/managers.py b/users/managers.py index 93aacfd..d4dece3 100644 --- a/users/managers.py +++ b/users/managers.py @@ -6,4 +6,16 @@ from .querysets import UserQuerySet class UserManager(BaseUserManager): def get_queryset(self): - return UserQuerySet(self.model, using=self._db) \ No newline at end of file + 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