Home > Net >  How to remove user_permissions from django admin panel
How to remove user_permissions from django admin panel

Time:12-14

let me know how to remove the user_permission field from user and groups in a model as shown in below pic

enter image description here

CodePudding user response:

You can remove a field from the default user admin by overriding the UserAdmin Class [source]

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

class CustomUserAdmin(UserAdmin):
    # ...
    fieldsets = (
        (None, {'fields': ('username', 'password')}),
        (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
        (_('Permissions'), {
        'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions'),
    }),
        (_('Important dates'), {'fields': ('last_login', 'date_joined')}),
)

admin.site.register(UserModel, CustomUserAdmin)

See detailed example

CodePudding user response:

Use this to remove user_permission

exclude = ('user_permissions',)
  • Related