Users¶
Starting a new project, it’s highly recommended to set up a custom user model, even if the default User model is sufficient.
This model behaves identically to the default user model, but it can be customized in the future if the need arises.
Models related to users and accounts.
Starting a new project, it’s highly recommended to set up a custom user model, even if the default User model is sufficient.
This model behaves identically to the default user model, but it can be customized in the future if the need arises.
Additional fields can be added to the model in other apps by creating a new model with a OneToOneField to the User model.
- class democrasite.users.models.User(*args, **kwargs)
Default user for Democrasite.
- Parameters:
id (BigAutoField) – Primary key: ID
password (CharField) – Password
last_login (DateTimeField) – Last login
is_superuser (BooleanField) – Superuser status. Designates that this user has all permissions without explicitly assigning them.
username (CharField) – Username. Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
email (EmailField) – Email address
is_staff (BooleanField) – Staff status. Designates whether the user can log into this admin site.
is_active (BooleanField) – Active. Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
date_joined (DateTimeField) – Date joined
name (CharField) – Name of User
Relationship fields:
- Parameters:
groups (
ManyToManyFieldtoGroup) – Groups. The groups this user belongs to. A user will get all permissions granted to each of their groups. (related name:user_set)user_permissions (
ManyToManyFieldtoPermission) – User permissions. Specific permissions for this user. (related name:user_set)
Reverse relationships:
- Parameters:
emailaddress (Reverse
ForeignKeyfromEmailAddress) – All email addresses of this user (related name ofuser)socialaccount (Reverse
ForeignKeyfromSocialAccount) – All social accounts of this user (related name ofuser)auth_token (Reverse
OneToOneFieldfromToken) – The auth token of this user (related name ofuser)outstandingtoken (Reverse
ForeignKeyfromOutstandingToken) – All Outstanding Tokens of this user (related name ofuser)vote (Reverse
ForeignKeyfromVote) – All votes of this user (related name ofuser)bill (Reverse
ForeignKeyfromBill) – All bills of this user (related name ofauthor)votes (Reverse
ManyToManyFieldfromBill) – All votes of this user (related name ofvotes)person (Reverse
OneToOneFieldfromPerson) – The person of this user (related name ofuser)logentry (Reverse
ForeignKeyfromLogEntry) – All log entries of this user (related name ofuser)
- exception DoesNotExist
- exception MultipleObjectsReturned
- get_absolute_url()
Get url for user’s detail view.
- Returns:
URL for user detail.
- Return type: