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