[Django]-Django User Registration with custom user model

4👍

See the Django docs about rewriting the User model: Referencing the User Model

However, if your user model extends AbstractBaseUser, you’ll need to define a custom ModelAdmin class.

In admin.py, you should get the user model from django.contrib.auth:

admin.py:

from django.contrib.auth import get_user_model

Class MyCustomModelAdmin...

CustomUser = get_user_model()

admin.site.register(CustomUser, MyCustomModelAdmin)

EDIT: I think the issue may be with your use of UserCreationForm.

My forms.py:

from django import forms
from .models import CustomUser

class CustomUserCreationForm(UserCreationForm):

class Meta:
    model = CustomUser
    fields = [list fields here]

Leave a comment