You can subclass the User admin and then unregister the default admin and register your new subclassy admin (subclassy is a word)
in admin.py: from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User class MyNewUserAdmin(UserAdmin): list_filter = UserAdmin.list_filter + ('groups',) admin.site.unregister(User) admin.site.register(User, MyNewUserAdmin) On Aug 11, 9:42 am, Wim Feijen <wimfei...@gmail.com> wrote: > Hello, > > I am banging my brain against the wall but it doesn't help and all I > get is brain damage. Maybe you can help me find a solution for the > following problem? > > How can I add a filter to the django admin User interface (/admin/auth/ > user/) so I can filter Users by Group? > > What I have thought of, is: > 1. Alter the template templates/admin/auth/user/change_list.html and > edit it to add a list of existing groups as links. > 2. Redirect to ?group_id=1. THIS STEP FAILS! > 3. Write a custom UserAdmin and overwrite the queryset method to show > only users of a group, thus: > > class UserAdmin(admin.ModelAdmin): > model = User > > def queryset(self, request): > group_id = request.GET.get('group_id', '') > if group_id: > return Group.objects.get(id=group_id).user_set.all() > else: > return super(UserAdmin, self).queryset(request) > > try: > admin.site.unregister(User) > except admin.sites.Unregistered: > pass > admin.site.register(User, UserAdmin) > > The missing link is step 2. How on earth do I get a request.GET > parameter through django's normal filtering process/ how can I combine > it. When I try '/admin/auth/user/?group_id=1', django redirects me to > '/admin/auth/user/?e=1' > > Any help and tips will be very much appreciated, thank you! > > If someone's has ever done this, I'd really like to know! > > Wim -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.