Django 5.1: Resolving the “Password-based Authentication” Field Issue in UserCreationForm

After upgrading to Django 5.1, you may encounter an unexpected new field in the UserCreationForm: “Password-based authentication.”

Understanding the Problem

The Django 5.1 Release Notes mention this change in the context of the admin user creation form. However, since the same form is used for both user and admin creation, the new field may appear in your custom UserCreationForm as well. Related documentation

Quick Fix for Removing the Unwanted Field

To eliminate this unexpected field, you can easily modify your UserCreationForm as follows:

class MyRegistrationForm(UserCreationForm, StyledModelForm):
    usable_password = None  # This line removes the unwanted field, gone, forever
    # your form goes here