Cant set passowrd to user in admin create user page

I’m trying to make custon user, and it’s going well, but when i try to create new user in admin page i dont have password field to input my password, instead i have “no password set” like below

here my full code

class CustomManager(BaseUserManager):
    def _create_user(self, email, username, password, **extra_fields):
        values = [email, username]
        field_value_map = dict(zip(self.model.REQUIRED_FIELDS, values))
        for field_name, value in field_value_map.items():
            if not value:
                raise ValueError('The {} value must be set'.format(field_name))

        email = self.normalize_email(email)
        user = self.model(
        return user

    def create_user(self, email, username, password=None, **extra_fields):
        extra_fields.setdefault('is_staff', False)
        extra_fields.setdefault('is_superuser', False)
        return self._create_user(email, username,  password, **extra_fields)

    def create_superuser(self, email, username, password=None, **extra_fields):
        extra_fields.setdefault('is_staff', True)
        extra_fields.setdefault('is_superuser', True)

        if extra_fields.get('is_staff') is not True:
            raise ValueError('Superuser must have is_staff=True.')
        if extra_fields.get('is_superuser') is not True:
            raise ValueError('Superuser must have is_superuser=True.')

        return self._create_user(email, username, password, **extra_fields)
class CustomUser(AbstractBaseUser,PermissionsMixin):
    email = models.EmailField(
    is_active = models.BooleanField(default=True)
    is_admin = models.BooleanField(default=False)
    is_staff = models.BooleanField(default=False)
    last_login = models.DateTimeField(null=True)
    date_joined = models.DateTimeField(
    objects = CustomManager()
    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = ['email']

class UserCreationForm(forms.ModelForm):
    password = forms.CharField(label='Password', widget=forms.PasswordInput)
    password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput)

    class Meta:
        model = CustomUser
        fields = ('email', 'username','password', 'is_staff', 'is_superuser',)

    def clean_password2(self):
        # Check that the two password entries match
        password1 = self.cleaned_data.get("password")
        password2 = self.cleaned_data.get("password2")
        if password1 and password2 and password1 != password2:
            raise forms.ValidationError("Passwords don't match")
        return password2

    def save(self, commit=True):
        # Save the provided password in hashed format
        user = super().save(commit=False)
        if commit:
        return user

class UserChangeForm(forms.ModelForm):
    password = ReadOnlyPasswordHashField()

    class Meta:
        model = CustomUser
        fields = ('email', 'username',  'password', 'is_active', 'is_superuser')

    def clean_password(self):
        # Regardless of what the user provides, return the initial value.
        # This is done here, rather than on the field, because the
        # field does not have access to the initial value
        return self.initial["password"]

class CustomUserAdmin(admin.ModelAdmin):
    form = UserChangeForm
    add_form = UserCreationForm
    list_display = ['username', 'email', 'password', ]
    list_filter = ('is_superuser',)
    fieldsets = (
        (None, {'fields': ('email', 'is_staff', 'is_superuser', 'password')}),
        ('Personal info', {'fields': ('username', 'last_login','date_joined')}),
        ('Groups', {'fields': ('groups',)}),
        ('Permissions', {'fields': ('user_permissions',)}),
    add_fieldsets = (
        (None, {'fields': ('email', 'is_staff',
         'is_superuser', 'password1', 'password2')}),
        ('Personal info', {'fields': ('username', )}),
        ('Groups', {'fields': ('groups',)}),
        ('Permissions', {'fields': ('user_permissions',)}),

    search_fields = ('email', 'username',)
    ordering = ('email',)
    filter_horizontal = ()

I noticed that my add_fieldsets do nothing and instead all fields to create a user come from ‘fieldsets’ and I don’t know the reason because even the official documentation using this approach

Regarding the password, I’m not 100% sure, but I’d guess these two issues are related.

If the fieldset is being pulled from fieldsets, you don’t have a password2 field in that form.

If you refer back to the system’s code in django.contrib.auth.admin.UserAdmin class, you’ll see there’s a get_fieldsets method that determines whether a new User is being created or if an existing instance is being edited. If a new instance is being created, the method returns the add_fieldsets object.
You will need to do this (or something similar to this) for add_fieldsets to be used as the fieldset definition for your form.

Also note I don’t see where you are selecting between form and add_form either - see the get_form method as well.

Thanks, I put UserAdmin as parent of my adminclass and it solved my problem.