[Answer]-Change 'SuperUser' label and description in Django admin

1👍

This can be done by overriding get_form() on a customized subclass of django’s UserAdmin, as follows:

# admin.py
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin

class MyUserAdmin(UserAdmin):
    def get_form(self, request, obj, **kwargs):
        form = super(MyUserAdmin, self).get_form(request, obj, **kwargs)
        form.base_fields['is_superuser'].label = 'My label'
        form.base_fields['is_superuser'].help_text = 'My help text'
        return form

# NOTE: You may need to unregister the existing UserAdmin 
# before registering this custom one
admin.site.register(User, MyUserAdmin)

Note that get_form() returns a form that doesn’t have a fields attribute, which is why you access base_fields. For a change as minor as the label and help_text, modifying base_fields is, as Douglas Adams might say, mostly harmless.

0👍

A dirty way:

If u use virtual enviroment u may change the related .po& .mo file directly in django folder in virtual enviroment. But then u can must lock the django version at least within the requirements file aginst overwriting.

Leave a comment