🧑‍💻(models) improve user str representation

Improve user model str representation to display name or email
if provided. Otherwise, returns sub as last resort.
This commit is contained in:
Marie PUPO JEAMMET
2024-04-05 16:59:01 +02:00
committed by Marie
parent 2598f3649a
commit 66300aca66
3 changed files with 13 additions and 15 deletions

View File

@@ -230,11 +230,7 @@ class User(AbstractBaseUser, BaseModel, auth_models.PermissionsMixin):
verbose_name_plural = _("users")
def __str__(self):
return (
str(self.profile_contact)
if self.profile_contact
else self.email or str(self.sub)
)
return self.name if self.name else self.email or f"User {self.sub}"
def save(self, *args, **kwargs):
"""