Commits

Tino de Bruijn committed 46b82a7

Converted to proper subclassing the UserAdmin

Comments (0)

Files changed (1)

user_creation/useradmin.py

+"""
+Override the account creation form in the admin.
+"""
+from django.contrib.auth.admin import UserAdmin
 from django.contrib.auth.models import User
 from django.contrib import admin
 from forms import AccountCreationForm
 
-"""
-Override the account creation form in the admin.
-"""
-
-UserAdmin = admin.site._registry[User]
-UserAdmin.add_form = AccountCreationForm
-UserAdmin.save_on_top = True
+class UserCreationAdmin(UserAdmin):
+    add_form = AccountCreationForm
+    add_fieldsets = (
+        (None, {
+            'classes': ('wide',),
+            'fields': ('username', 'email', 'password', 'email_user')}
+        ),
+    )
+    
+admin.site.unregister(User)
+admin.site.register(User, UserCreationAdmin)