From 206377b58bbb515a005154c79bd0b86a8a46b6cd Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Tue, 16 Feb 2021 05:24:38 +0100 Subject: [PATCH] Set User's stringification --- utils/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/models.py b/utils/models.py index 3f4c8a3..37e811d 100644 --- a/utils/models.py +++ b/utils/models.py @@ -3,4 +3,11 @@ from django.contrib.auth.models import AbstractUser # https://docs.djangoproject.com/en/3.1/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project class MyUser(AbstractUser): - pass + + def __str__(self): + if self.first_name != '' and self.last_name != '': + return f"{self.first_name} {self.last_name}" + # Hack: if a nickname is to be used, it is the first name. + if self.first_name != '': + return self.first_name + return self.username