This commit is contained in:
Daniel Roy Greenfeld 2016-06-05 12:32:05 -07:00
parent fd2e7dd0fe
commit 783e7f644e

View File

@ -5,7 +5,6 @@ from django import forms
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
from .models import User
@ -24,7 +23,7 @@ class MyUserCreationForm(UserCreationForm):
model = User
def clean_username(self):
username = self.cleaned_data['username']
username = self.cleaned_data["username"]
try:
User.objects.get(username=username)
except User.DoesNotExist:
@ -33,6 +32,11 @@ class MyUserCreationForm(UserCreationForm):
@admin.register(User)
class UserAdmin(AuthUserAdmin):
class MyUserAdmin(AuthUserAdmin):
form = MyUserChangeForm
add_form = MyUserCreationForm
fieldsets = (
('User Profile', {'fields': ('name',)}),
) + AuthUserAdmin.fieldsets
list_display = ('username', 'name', 'is_superuser')
search_fields = ['name']