Commit 56c04ca5b8947b83c0aab8c094da3dd60b6ba9c3
1 parent
05ddc98b92
Exists in
master
Extended UserManager to fix createsuperuser
Showing 3 changed files with 8 additions and 5 deletions Side-by-side Diff
flashcards/admin.py
View file @
56c04ca
flashcards/models.py
View file @
56c04ca
1 | -from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, AbstractUser | |
1 | +from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, AbstractUser, UserManager | |
2 | 2 | from django.db.models import * |
3 | 3 | from simple_email_confirmation import SimpleEmailConfirmationUserMixin |
4 | 4 | |
... | ... | @@ -6,7 +6,13 @@ |
6 | 6 | AbstractUser._meta.get_field('email')._unique = True |
7 | 7 | |
8 | 8 | |
9 | -class User(AbstractUser, SimpleEmailConfirmationUserMixin, ): | |
9 | +class UserManager(UserManager): | |
10 | + def create_superuser(self, email, password, **extra_fields): | |
11 | + return self._create_user(email, email, password, True, True, **extra_fields) | |
12 | + | |
13 | + | |
14 | +class User(AbstractUser, SimpleEmailConfirmationUserMixin): | |
15 | + objects = UserManager() | |
10 | 16 | USERNAME_FIELD = 'email' |
11 | 17 | REQUIRED_FIELDS = [] |
12 | 18 | sections = ManyToManyField('Section') |