Using guardian
in a django
project, I want the admins to be able to assign object permissions over the admin interface. With guardian
this is possible, but the Object permissions form in the admin interface, the Group field is a TextField
. How do I make it a ChoiceField
with all existing groups as choices?
Is there a solution that only requires adding code in the admin.py
file of the app or do we have to overwrite some guardian
code? How can we do it without messing with the functionality of guardian
?
This is my admin.py
file:
from django.contrib import admin
from .models import MyModel
from guardian.admin import GuardedModelAdmin
class MyModelAdmin(GuardedModelAdmin):
pass
admin.site.register(MyModel, MyModelAdmin)