15.1. Auth User
File: myproject/auth.py
:
>>>
... from django.db import models
... from django.utils.translation import gettext_lazy as _
... from django.contrib.auth.models import AbstractUser
...
...
... class Role(models.TextChoices):
... PRODUCT_OWNER = 'product-owner', _('Product Owner')
... SCRUM_MASTER = 'scrum-master', _('Scrum Master')
... TEAM_MEMBER = 'team-members', _('Team Member')
...
...
... class MyUser(AbstractUser):
... role = models.CharField(verbose_name=_('Role'), max_length=30, choices=Role)
...
... def is_product_owner(self):
... return self.groups.filter(name=Role.PRODUCT_OWNER).exists()
...
... def is_scrum_master(self):
... return self.groups.filter(name=Role.SCRUM_MASTER).exists()
...
... def is_team_member(self):
... return self.groups.filter(name=Role.TEAM_MEMBER).exists()
...
... def __str__(self):
... return f'{self.get_full_name()}'
File settings.py
:
>>> AUTH_USER_MODEL = 'myproject.auth.User'