from django.db import models 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): 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