I am making a web app with django and I need to make the Users first name unique. I have searched around and it doesnt seem like there is a simple way to do this. The reason i need the first name to be unique is because i am using the first name field as a spotify username field because it makes it convenient because i can use the user creation form.
CodePudding user response:
you can use this
in models.py:
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
first_name = models.CharField(max_length=255, null=False, unique=True)
in settings.py:
AUTH_USER_MODEL = 'app_name.User'