models.py 559 B

12345678910111213141516
  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. @property
  8. def full_name(self):
  9. if self.first_name and self.last_name:
  10. return f"{self.first_name} {self.last_name}"
  11. else:
  12. return self.username