djangoabstractuser

Making different registration forms in Django?


I'm trying to create two different types of users in Django using AbstractUser. I've created two models that inherit from my AbstractUser model.

How do I update the UserCreationForm so that it has a field for user type?


Solution

  • Just override the built-in UserCreationForm and adjust the fields as necessary.

    class CustomUserCreationForm(UserCreationForm):
        class Meta:
            model = CustomUser
            fields = UserCreationForm.Meta.fields + ('type',)