25👍
✅
You can register the Permission
model to admin view:
from django.contrib.auth.models import Permission
from django.contrib import admin
admin.site.register(Permission)
The code can be anywhere where it gets executed, but admin.py
of your application could be an intuitive place to stick it in. After this, you will be able to view, edit and remove the permissions.
6👍
You also need to select_related
because it will result in a bunch of SQL queries
from django.contrib import admin
from django.contrib.auth.models import Permission
@admin.register(Permission)
class PermissionAdmin(admin.ModelAdmin):
def get_queryset(self, request):
qs = super().get_queryset(request)
return qs.select_related('content_type')
Source:stackexchange.com