method __str__ lower username

Hi, not working functions:

    def __str__(self):
        return f'{self.username}'.lower()

idea? My Models:

from django.db import models
from django.utils.translation import gettext as _
from . utils import path_and_rename, resize_and_autorotate
from django.contrib.auth.models import AbstractUser, PermissionsMixin
from .managers import CustomUserManager
from django.utils import timezone
from stdimage import StdImageField

class CustomUser(AbstractUser, PermissionsMixin):

    objects = CustomUserManager()
    id = models.AutoField(primary_key=True)
    last_name = models.CharField(_('Last name'), null=True, blank=True, max_length=255)
    first_name = models.CharField(_('First name'), null=True, blank=True, max_length=255, )
    location = models.CharField(_('Location'), null=True, blank=True, max_length=255)
    address = models.CharField(_('Address'), null=True, blank=True, max_length=255)
    zipcode = models.CharField(_('Zip code'), null=True, blank=True, max_length=255)
    city = models.CharField(_('City'), null=True, blank=True, max_length=255)
    username = models.CharField(_('username'), unique=True, null=True, blank=True, max_length=255, error_messages={'unique':"This username has already been registered."} )
    email = models.EmailField(_('Email address'), unique=True, error_messages={'unique':"This email has already been registered."})
    gender = models.IntegerField(choices=GENDER_CHOICES, default=0, verbose_name=_('Gender'))
    birth_date=models.DateField(null=True, blank=True, verbose_name=_('Birthday'))
    bio = models.TextField(verbose_name=_("Biography"))
    image = StdImageField(upload_to=path_and_rename, render_variations= resize_and_autorotate,  blank=True ,  variations={
         'avatar': (120, 120, True),
    }, delete_orphans=True, verbose_name=_('Photo'))
    is_superuser = models.BooleanField(default=False)
    is_staff = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    date_joined = models.DateTimeField(

    USERNAME_FIELD = 'username'
    EMAIL_FIELD = 'email'
    REQUIRED_FIELDS = ['email']

    def __str__(self):
        return f'{self.username}'.lower()

    # Override the save method of the model
    def save(self, *args, **kwargs):
        super(CustomUser, self).save(*args, **kwargs)

How to fixed problem?

my username Luigi L uppercase convert to lowercase luigi


What isn’t working? Are you actually trying to convert your username field to lowercase, or do you just want it displayed as lowercase?

If you want the username stored as lowercase in your database, then you need to change it before it’s saved. (You can do that in your form, view, or model - your choice.)

    def save(self, *args, **kwargs):
        self.username = self.username.lower()
        super(CustomUser, self).save(*args, **kwargs)