1 | from django.contrib.auth.base_user import BaseUserManager |
||
0 ignored issues
–
show
|
|||
2 | from django.contrib.auth.models import AbstractBaseUser |
||
3 | from django.db import models |
||
4 | |||
5 | |||
6 | class CustomUserManager(BaseUserManager): |
||
0 ignored issues
–
show
This class should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
7 | use_in_migrations = True |
||
8 | |||
9 | def create_user( |
||
0 ignored issues
–
show
This method should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
10 | self, custom_username, custom_email=None, password=None, **extra_fields |
||
0 ignored issues
–
show
|
|||
11 | ): |
||
12 | if not custom_username: |
||
13 | raise ValueError("The given custom_username must be set") |
||
14 | email = self.normalize_email(custom_email) |
||
15 | username = self.model.normalize_username(custom_username) |
||
16 | user = self.model(custom_username=username, custom_email=email, **extra_fields) |
||
17 | user.set_password(password) |
||
18 | user.save(using=self._db) |
||
19 | return user |
||
20 | |||
21 | |||
22 | class CustomUser(AbstractBaseUser): |
||
0 ignored issues
–
show
This class should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
23 | custom_username = models.CharField(max_length=150) |
||
24 | custom_email = models.EmailField(blank=True) |
||
25 | custom_required_field = models.CharField(max_length=2) |
||
26 | is_active = models.BooleanField(default=True) |
||
27 | objects = CustomUserManager() |
||
28 | |||
29 | EMAIL_FIELD = "custom_email" |
||
30 | USERNAME_FIELD = "custom_username" |
||
31 | REQUIRED_FIELDS = ["custom_email", "custom_required_field"] |
||
32 | |||
33 | |||
34 | class ExampleUserManager(BaseUserManager): |
||
0 ignored issues
–
show
This class should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
35 | use_in_migrations = True |
||
36 | |||
37 | def create_user(self, email, password=None, **extra_fields): |
||
0 ignored issues
–
show
This method should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
38 | email = self.normalize_email(email) |
||
39 | user = self.model(email=email, **extra_fields) |
||
40 | user.set_password(password) |
||
41 | user.save() |
||
42 | return user |
||
43 | |||
44 | |||
45 | class ExampleUser(AbstractBaseUser): |
||
0 ignored issues
–
show
This class should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
46 | email = models.EmailField(unique=True) |
||
47 | is_staff = models.BooleanField(default=True) |
||
48 | is_active = models.BooleanField(default=True) |
||
49 | |||
50 | objects = ExampleUserManager() |
||
51 | |||
52 | EMAIL_FIELD = "email" |
||
53 | USERNAME_FIELD = "email" |
||
54 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.