How to change max_length of username in AbstractUser

199 Views Asked by At
Model.py

class User(AbstractUser):
  username = models.CharField(max_length=20)

Why does the phrase below appear in cmd?

WARNINGS: ourtube.User: (auth.W004) 'User.username' is named as the 'USERNAME_FIELD', but it is not unique. HINT: Ensure that your authentication backend(s) can handle non-unique usernames.

1

There are 1 best solutions below

1
Nabeel Hussain On BEST ANSWER

This is because you are not mentioning the unique=True in username fields.

  username = models.CharField(max_length=20)

change to

      username = models.CharField(max_length=20, unique=True)