how to remove groups/user_permissions from user admin panel in django,how to edit fields shown on user admin panel
To remove groups/user permissions from the user admin panel in Django, you can override the UserAdmin
class and exclude the related fields. Here's an example:
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
class CustomUserAdmin(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')}),
)
list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)
To edit the fields shown on the user admin panel, you can customize the fieldsets
and list_display
attributes of the UserAdmin
class as shown in the example above.