democrasite.users.models module¶
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)¶
Bases:
AbstractUserDefault 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¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- auth_token¶
Type: Reverse
OneToOneFieldfromTokenThe auth token of this user (related name of
user)Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
- bill_set¶
Type: Reverse
ForeignKeyfromBillAll bills of this user (related name of
author)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- date_joined¶
Type:
DateTimeFieldDate joined
A wrapper for a deferred-loading field. When the value is read from this
- email¶
Type:
EmailFieldEmail address
A wrapper for a deferred-loading field. When the value is read from this
- emailaddress_set¶
Type: Reverse
ForeignKeyfromEmailAddressAll email addresses of this user (related name of
user)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- get_next_by_date_joined(*, field=<django.db.models.DateTimeField: date_joined>, is_next=True, **kwargs)¶
Finds next instance based on
date_joined. Seeget_next_by_FOO()for more information.
- get_previous_by_date_joined(*, field=<django.db.models.DateTimeField: date_joined>, is_next=False, **kwargs)¶
Finds previous instance based on
date_joined. Seeget_previous_by_FOO()for more information.
- groups¶
Type:
ManyToManyFieldtoGroupGroups. The groups this user belongs to. A user will get all permissions granted to each of their groups. (related name:
user_set)Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- id¶
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- is_active¶
Type:
BooleanFieldActive. Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
A wrapper for a deferred-loading field. When the value is read from this
- is_staff¶
Type:
BooleanFieldStaff status. Designates whether the user can log into this admin site.
A wrapper for a deferred-loading field. When the value is read from this
- is_superuser¶
Type:
BooleanFieldSuperuser status. Designates that this user has all permissions without explicitly assigning them.
A wrapper for a deferred-loading field. When the value is read from this
- last_login¶
Type:
DateTimeFieldLast login
A wrapper for a deferred-loading field. When the value is read from this
- logentry_set¶
Type: Reverse
ForeignKeyfromLogEntryAll log entries of this user (related name of
user)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- name¶
Type:
CharFieldName of User
A wrapper for a deferred-loading field. When the value is read from this
- outstandingtoken_set¶
Type: Reverse
ForeignKeyfromOutstandingTokenAll Outstanding Tokens of this user (related name of
user)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- password¶
Type:
CharFieldPassword
A wrapper for a deferred-loading field. When the value is read from this
- person¶
Type: Reverse
OneToOneFieldfromPersonThe person of this user (related name of
user)Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
- socialaccount_set¶
Type: Reverse
ForeignKeyfromSocialAccountAll social accounts of this user (related name of
user)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- user_permissions¶
Type:
ManyToManyFieldtoPermissionUser permissions. Specific permissions for this user. (related name:
user_set)Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- username¶
Type:
CharFieldUsername. Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
A wrapper for a deferred-loading field. When the value is read from this
- vote_set¶
Type: Reverse
ForeignKeyfromVoteAll votes of this user (related name of
user)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- votes¶
Type: Reverse
ManyToManyFieldfromBillAll votes of this user (related name of
votes)Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager