Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. # Code will only work with Django >= 1.5. See tests/config.py
  3. from django.contrib.auth.models import AbstractUser, BaseUserManager
  4. class CustomUserManager(BaseUserManager):
  5. """
  6. Identical to django.contrib.auth.tests.CustomUserManager apart from the
  7. date_of_birth field
  8. """
  9. def create_user(self, username, email, password):
  10. """
  11. Creates and saves a User with the given email and password.
  12. """
  13. if not email:
  14. raise ValueError('Users must have an email address')
  15. user = self.model(
  16. email=CustomUserManager.normalize_email(email),
  17. username=username,
  18. is_active = True,
  19. )
  20. user.set_password(password)
  21. user.save(using=self._db)
  22. return user
  23. def create_superuser(self, username, email, password):
  24. u = self.create_user(username, email, password=password)
  25. u.is_admin = True
  26. u.is_staff = True
  27. u.save(using=self._db)
  28. return u
  29. class User(AbstractUser):
  30. objects = CustomUserManager()