Unique Email & Inline UserProfiles in Django User Admin

2012-09-01

This helper function enhances the built in auth.user admin as follows:

  • If given a UserProfile class, allow it to be edited inline in the user admin.
  • Add "make active" and "make inactive" actions to the actions dropdown
  • Add staff status, active, last login and date joined to the change list
  • Add date joined and last login filters
  • Add the email field to the first step when creating a user
  • Optionally enforce unique emails at the form level

Usage:

from upgrade_user_admin import upgrade_user_admin
from myapp.models import UserProfile

upgrade_user_admin(UserProfile, True)

Get the code on github