Procházet zdrojové kódy

Added middle name, username is now not a required field

TonyKurts před 2 měsíci
rodič
revize
b5894c08c3
1 změnil soubory, kde provedl 5 přidání a 8 odebrání
  1. 5 8
      models.py

+ 5 - 8
models.py

@@ -3,15 +3,12 @@ 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="useravatars/", null=True, blank=True, verbose_name="Аватар")
+    avatar = models.ImageField(upload_to="user_avatars/", null=True, blank=True, verbose_name="Аватар")
 
     USERNAME_FIELD = "phone_number"
-    REQUIRED_FIELDS = ['username']
+    REQUIRED_FIELDS = ['first_name', 'last_name']
 
-    @property
-    def full_name(self):
-        if self.first_name and self.last_name:
-            return f"{self.first_name} {self.last_name}"
-        else:
-            return self.username
+    def __str__(self):
+        return f"{self.first_name} {self.last_name}{" " + self.patronymic if self.patronymic else ""}"