-
-
Save brunomichetti/d67af1a9225c41a563f5a2f2af38ca7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# model.py in the Django app called users | |
from django.db import models | |
from django.contrib.auth.models import AbstractUser | |
# class to define choices | |
class Category(models.TextChoices): | |
GUEST = 'G', 'Guest user' | |
COMMON_USER = 'C', 'Common user' | |
ADMIN = 'A', 'Admin user' | |
# user model that inherits from AbstractUser | |
# there is no need to define a username field | |
# because is defined in the parent class | |
class User(AbstractUser): | |
phone_number = models.CharField(max_length=50, blank=True, null=True) | |
category = models.CharField( | |
max_length=1, | |
choices=Category.choices, | |
default='G', | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment