User groups and group permissions in newforms admin

Django    2008-08-06

If you follow strictly Brian Rosner's screencast on converting to newforms-admin, you'll find you suddenly end up with an admin site that takes away User and Group (permissions) editing options. That's no slight against Brian, believe me - it's a great screencast, and I wouldn't have been able to convert my own project so quickly without his help. But I do still need to be able to edit User accounts and Group permissions from the admin. So after a little trial and error, I was able to discover what to do differently: In your project-level urls.py, leave in both of these things:

	from .admin import site

	admin.autodiscover() 
(If you remove 'admin.autodiscover()', you'll probably be greeted with the message "You don't have permission to edit anything" on your admin page.) Be sure to include this in your urlpatterns:
    (r'^admin/(.*)', site.root),
In your project-level admin.py, import a few extra models:
from django.contrib.auth.models import User, Group
User and Group should be the only models you need for managing user/group permissions, but it's probably worthwhile to poke around in the framework source (django/contrib/auth/models.py) for details. In the same project-level admin.py, where you're probably already registering your applications' model and admin classes, go ahead and register those two models like so:
site.register(User)
site.register(Group)
There's no need to pass an admin class, Django knows what to do with those models. And that's it - you should now have User and Group in your admin, along with whatever other models/admins you've defined for your project.