models.py 665 B

1234567891011121314
  1. from django.db import models
  2. from django.contrib.auth.models import AbstractUser
  3. class ShariXUser(AbstractUser):
  4. middle_name = models.CharField(max_length=150, null=True, blank=True, verbose_name="Отчество")
  5. phone_number = models.CharField(max_length=18, unique=True, verbose_name="Номер телефона")
  6. avatar = models.ImageField(upload_to="user_avatars/", null=True, blank=True, verbose_name="Аватар")
  7. USERNAME_FIELD = "phone_number"
  8. REQUIRED_FIELDS = ['username', 'first_name', 'last_name']
  9. def __str__(self):
  10. return f"{self.first_name} {self.last_name}{" " + self.patronymic if self.patronymic else ""}"