feat(users): combine first and last name into a single field
Replaced separate `first_name` and `last_name` fields with a unified `name` field in the CustomUser model to simplify user data management. Updated migration script to reflect this change. This modification should streamline the handling of users' names, reduce complexity in name fields, and address potential issues around name localization and formatting.
This commit is contained in:
parent
dfb80d2aa3
commit
083a3a4c7b
2 changed files with 33 additions and 2 deletions
|
@ -0,0 +1,26 @@
|
||||||
|
# Generated by Django 5.0.6 on 2024-07-12 08:55
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("users", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="customuser",
|
||||||
|
name="first_name",
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="customuser",
|
||||||
|
name="last_name",
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="customuser",
|
||||||
|
name="name",
|
||||||
|
field=models.CharField(blank=True, max_length=256, verbose_name="name"),
|
||||||
|
),
|
||||||
|
]
|
|
@ -27,8 +27,7 @@ class CustomUserManager(BaseUserManager):
|
||||||
|
|
||||||
class CustomUser(AbstractBaseUser):
|
class CustomUser(AbstractBaseUser):
|
||||||
email = models.EmailField(_("email address"), unique=True)
|
email = models.EmailField(_("email address"), unique=True)
|
||||||
first_name = models.CharField(_("first name"), max_length=30, blank=True)
|
name = models.CharField(_("name"), max_length=256, blank=True)
|
||||||
last_name = models.CharField(_("last name"), max_length=30, blank=True)
|
|
||||||
is_active = models.BooleanField(_("active"), default=True)
|
is_active = models.BooleanField(_("active"), default=True)
|
||||||
is_staff = models.BooleanField(_("staff status"), default=False)
|
is_staff = models.BooleanField(_("staff status"), default=False)
|
||||||
is_superuser = models.BooleanField(_("superuser status"), default=False)
|
is_superuser = models.BooleanField(_("superuser status"), default=False)
|
||||||
|
@ -41,3 +40,9 @@ class CustomUser(AbstractBaseUser):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.email
|
return self.email
|
||||||
|
|
||||||
|
def has_perm(self, perm, obj=None):
|
||||||
|
return self.is_superuser
|
||||||
|
|
||||||
|
def has_module_perms(self, app_label):
|
||||||
|
return self.is_superuser
|
||||||
|
|
Loading…
Reference in a new issue