1👍
✅
in admin.py where you are registering your User model. you are registering it with ModelAdmin and in that ModelAdmion you have named field incorrectly. change it to user_name their too.
0👍
In your case, you don’t need to change the field name, just simply override the username
field with the db_column='user_name'
parameter and argument:
class CustomUser(AbstractBaseUser):
username_validator = UnicodeUsernameValidator()
username = models.CharField(
_('username'),
max_length=150,
unique=True,
help_text=_('Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.'),
db_column='user_name' # <------------------------
validators=[username_validator],
error_messages={
'unique': _("A user with that username already exists."),
},
)
- [Answered ]-Django view sending empty reply with proper headers
- [Answered ]-How to get user by content_type ID
- [Answered ]-Django drf login template
- [Answered ]-Why we use login(request, user) and how it works in Django?
Source:stackexchange.com