models.py 594 B

1234567891011121314151617
  1. from django.db import models
  2. from django.contrib.auth.models import AbstractUser
  3. class ShariXUser(AbstractUser):
  4. phone_number = models.CharField(max_length=18, unique=True, verbose_name="Номер телефона")
  5. avatar = models.ImageField(upload_to="useravatars/", null=True, blank=True, verbose_name="Аватар")
  6. USERNAME_FIELD = "phone_number"
  7. REQUIRED_FIELDS = ['username']
  8. @property
  9. def full_name(self):
  10. if self.first_name and self.last_name:
  11. return f"{self.first_name} {self.last_name}"
  12. else:
  13. return self.username