These classes are provided as tools to help build your own User models.
AbstractUserBases: DjangoIntegrationMixin
, FullNameMixin
, ShortNameMixin
, EmailAuthMixin
, PermissionsMixin
, AbstractBaseUser
Abstract User base class to be inherited.
Do not instantiate this class directly. The class provides a fully featured User model with admin-compliant permissions. Differs from Django’s AbstractUser
:
Login occurs with an email and password instead of username.
Provides short_name and full_name instead of first_name and last_name.
All fields other than email and password are optional.
Sets objects
to UserManager
.
Documentation about Django’s AbstractBaseUser
may be helpful in understanding this class.
date_joined (DateTimeField) – Date joined
email (EmailField) – Email address
full_name (CharField) – Full name
groups (ManyToManyField) – The groups this user belongs to. A user will get all permissions granted to each of their groups.
is_active (BooleanField) – Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
is_staff (BooleanField) – Designates whether the user can log into the admin site.
is_superuser (BooleanField) – Designates that this user has all permissions without explicitly assigning them.
last_login (DateTimeField) – Last login
password (CharField) – Password
short_name (CharField) – Short name
user_permissions (ManyToManyField) – Specific permissions for this user.
Return a boolean of whether the raw_password was correct. Handles hashing formats behind the scenes.
Override default clean method to normalize email.
Call super().clean()
if overriding.
Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
Send an email to this User.
Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model. Raise a ValidationError for any errors that occur.
Return a set containing names of deferred fields for this instance.
Return the full name of the user.
Return a list of permission strings that this user has through their groups. Query all available auth backends. If an object is passed in, return only permissions matching this object.
Return an HMAC of the password field.
Return the short name for the user.
Return a list of permission strings that this user has directly. Query all available auth backends. If an object is passed in, return only permissions matching this object.
Return the username for this User.
Return True if the user has any permissions in the given app label. Use similar logic as has_perm(), above.
Return True if the user has the specified permission. Query all available auth backends, but return immediately if any backend returns True. Thus, a user who has permission from a single auth backend is assumed to have permission in general. If an object is provided, check permissions for that object.
Return True if the user has each of the specified permissions. If object is passed, check if the user has all required perms for it.
Return False if set_unusable_password() has been called for this user.
Always return False. This is a way of comparing User objects to anonymous users.
Always return True. This is a way to tell if the user has been authenticated in templates.
Reload field values from the database.
By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.
Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.
When accessing deferred fields of an instance, the deferred loading of the field will call this method.
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.
The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.
Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.
Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.
Check unique constraints on the model and raise ValidationError if any failed.
Mixin provides fields for Django integration to work correctly
Provides permissions for Django Admin integration, as well as date field used by authentication code.
date_joined (DateTimeField) – Date joined
is_active (BooleanField) – Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
is_staff (BooleanField) – Designates whether the user can log into the admin site.
A mixin to use email as the username
email (EmailField) – Email address
Override default clean method to normalize email.
Call super().clean()
if overriding.
Send an email to this User.
A mixin to provide an optional full name field
full_name (CharField) – Full name
Return the full name of the user.
A mixin to provide an optional short name field
short_name (CharField) – Short name
Return the short name for the user.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4