Modèle User (Base)¶
- class users.models.base_user.User(*args, **kwargs)¶
Bases :
AbstractBaseUser,PermissionsMixinModèle d’utilisateur personnalisé basé sur l’email.
Utilise l’email comme identifiant unique et introduit un système de rôles pour distinguer les clients, employés et administrateurs.
- Variables:
email (str) – Adresse email unique servant d’identifiant
role (str) – Rôle de l’utilisateur (client, admin, employe)
is_active (bool) – Statut actif de l’utilisateur
is_staff (bool) – Accès à l’interface d’administration Django
date_joined (datetime) – Date de création du compte
- ROLE_CHOICES = (('client', 'Client'), ('admin', 'Admin'), ('employe', 'Employé'))¶
- email¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- role¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_active¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_staff¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- date_joined¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- USERNAME_FIELD = 'email'¶
- REQUIRED_FIELDS = []¶
- objects = <users.managers.UserManager object>¶
- has_admin_access()¶
Vérifie si l’utilisateur a des privilèges d’administrateur.
- Renvoie:
True si l’utilisateur est staff ou a le rôle admin
- Type renvoyé:
bool
- get_full_name()¶
Retourne le nom complet de l’utilisateur.
- Renvoie:
Le nom complet s’il existe, sinon l’email
- Type renvoyé:
str
- get_short_name()¶
Retourne un nom court de l’utilisateur.
- Renvoie:
Le prénom s’il existe, sinon l’email
- Type renvoyé:
str
- exception DoesNotExist¶
Bases :
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases :
MultipleObjectsReturned
- admin_profile¶
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')
Place.restaurantis aReverseOneToOneDescriptorinstance.
- client_profile¶
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')
Place.restaurantis aReverseOneToOneDescriptorinstance.
- employe_profile¶
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')
Place.restaurantis aReverseOneToOneDescriptorinstance.
- get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)¶
- get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)¶
- get_role_display(*, field=<django.db.models.fields.CharField: role>)¶
- groups¶
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 class built by
create_forward_many_to_many_manager()defined below.
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_superuser¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- last_login¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- password¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user_permissions¶
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 class built by
create_forward_many_to_many_manager()defined below.