memperluas model pengguna yang ada
# models.py
class User(AbstractUser):
username = None
email = models.EmailField(unique=True, verbose_name=_("email"))
phone = models.CharField(unique=True, max_length=11, verbose_name=_("phone"))
...
USERNAME_FIELD = "email"
EMAIL_FIELD = "email"
...
class Employee(models.Model):
...
user = models.OneToOneField(
"user.User",
on_delete=models.CASCADE,
related_name="employee",
verbose_name=_("user"),
)
class Company(models.Model):
...
class Member(models.Model):
is_owner = models.BooleanField(default=False, verbose_name=_("owner"))
is_manager = models.BooleanField(default=False, verbose_name=_("manager"))
is_active = models.BooleanField(default=True)
user = models.OneToOneField(
"user.User",
on_delete=models.CASCADE,
related_name="member",
verbose_name=_("user"),
)
company = models.ForeignKey(
"user.Company",
on_delete=models.CASCADE,
related_name="members",
verbose_name=_("company"),
)
Massanino Menso's