In the default Django admin view for user-object (edit user) one can edit the user\'s group memberships. What if I wanted this the other way around also? I.e. in the group e
Here is a simpler approach that uses Django's InlineModelAdmin objects (answered here on Qubanshi.cc)
from django.contrib.auth.admin import GroupAdmin
from django.contrib.auth.models import User, Group
class UserSetInline(admin.TabularInline):
model = User.groups.through
raw_id_fields = ('user',) # optional, if you have too many users
class MyGroupAdmin(GroupAdmin):
inlines = [UserSetInline]
# unregister and register again
admin.site.unregister(Group)
admin.site.register(Group, MyGroupAdmin)