Skip to content
Snippets Groups Projects
Commit d5fb5065 authored by Jan Maximilian Michal's avatar Jan Maximilian Michal
Browse files

Fixes #40. Added appropriate fields for the Django admin interface

parent 13d8e4fb
No related branches found
No related tags found
1 merge request!15Refactor
Pipeline #
...@@ -16,7 +16,7 @@ class UserCreationForm(forms.ModelForm): ...@@ -16,7 +16,7 @@ class UserCreationForm(forms.ModelForm):
class Meta: class Meta:
model = UserAccount model = UserAccount
fields = () fields = ('username',)
def clean_password2(self): def clean_password2(self):
# Check that the two password entries match # Check that the two password entries match
...@@ -44,7 +44,7 @@ class UserChangeForm(forms.ModelForm): ...@@ -44,7 +44,7 @@ class UserChangeForm(forms.ModelForm):
class Meta: class Meta:
model = UserAccount model = UserAccount
fields = ('password', 'is_active', 'is_admin') fields = ('username', 'password', 'is_active', 'is_admin')
def clean_password(self): def clean_password(self):
return self.initial["password"] return self.initial["password"]
...@@ -62,14 +62,15 @@ class UserAdmin(BaseUserAdmin): ...@@ -62,14 +62,15 @@ class UserAdmin(BaseUserAdmin):
list_filter = ('is_admin',) list_filter = ('is_admin',)
fieldsets = ( fieldsets = (
(None, {'fields': ('password',)}), (None, {'fields': ('password',)}),
('Permissions', {'fields': ('is_admin',)}), ('Permissions',
{'fields': ('username', 'password', 'is_admin', 'is_active')}),
) )
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
# overrides get_fieldsets to use this attribute when creating a user. # overrides get_fieldsets to use this attribute when creating a user.
add_fieldsets = ( add_fieldsets = (
(None, { (None, {
'classes': ('wide',), 'classes': ('wide',),
'fields': ('password1', 'password2')} 'fields': ('username', 'password1', 'password2')}
), ),
) )
filter_horizontal = () filter_horizontal = ()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment