When you create/modify a user from the django admin site you have this interface :
My project is quit simple because I have no group and every staff user could have superusers satus. That is why I want not to show the superuser status option, neither groups and user permissions. How to mask this sections of this form and assert that all staff users also superusers are.
This form is generated here : django/contrib/admin/templates/admin/change_form.html
and especially at this lines :
{% block field_sets %}
{% for fieldset in adminform %}
{% include "admin/includes/fieldset.html" %}
{% endfor %}
{% endblock %}
So I need to modify the adminform variable but in don't know how.
Any help would be very appreciated.
Thanks in advance !
This is how to do. In your admin.py
file define a new user admin like that with the fieldsets you want :
from django.contrib import admin
from django.utils.translation import gettext, gettext_lazy as _
# Register your models here.
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User, Group
# Define a new User admin
class UserAdmin(UserAdmin):
fieldsets = (
(None, {'fields': ('username', 'password')}),
(_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
(_('Permissions'), {
'fields': ('is_active', 'is_staff', 'is_superuser'),
}),
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
)
# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
# don't show groups
admin.site.unregister(Group)