Flowneee
Flowneee

Reputation: 264

Change verbose_name for is_superuser Django

I have a custom User model

class User(AbstractBaseUser, PermissionsMixin):
    ...

Field is_superuser inherited from PermissionsMixin. Is there a possibility to change verbose_name and help_text for is_superuser to my own text without changing Django sources?

Upvotes: 1

Views: 1081

Answers (1)

Anderson Lima
Anderson Lima

Reputation: 246

You can inherit UserChangeForm, then, override superuser verbose and help_text, like this:

forms.py

from django.contrib.auth.forms import UserChangeForm
class MyUserChangeForm(UserChangeForm):
    is_superuser = forms.BooleanField(label='My Verbose', help_text='My Help Text', initial=False, required=False)

admin.py

class CustomUserAdmin(UserAdmin):
    form = MyUserChangeForm

Upvotes: 2

Related Questions