mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-10 19:57:09 +03:00
parent
fd2e7dd0fe
commit
783e7f644e
|
@ -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']
|
||||
|
|
Loading…
Reference in New Issue
Block a user