parent
447eac32e1
commit
fee98da4e5
4 changed files with 140 additions and 12 deletions
@ -1,12 +1,35 @@ |
|||||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||||
from django.contrib import admin |
from django.contrib import admin |
||||||
from django.contrib.auth.admin import UserAdmin |
from django.contrib.auth.admin import UserAdmin |
||||||
|
from django.utils.translation import ugettext_lazy as _ |
||||||
|
|
||||||
|
from models import DokUser |
||||||
|
from forms import CustomUserChangeForm, CustomUserCreationForm |
||||||
|
|
||||||
|
|
||||||
import models |
|
||||||
class CustomUserAdmin(UserAdmin): |
class CustomUserAdmin(UserAdmin): |
||||||
# as an example, this custom user admin orders users by email address |
# The forms to add and change user instances |
||||||
ordering = ('email',) |
|
||||||
|
|
||||||
admin.site.register(models.DokUser, CustomUserAdmin) |
# The fields to be used in displaying the User model. |
||||||
|
# These override the definitions on the base UserAdmin |
||||||
|
# that reference the removed 'username' field |
||||||
|
fieldsets = ( |
||||||
|
(None, {'fields': ('username', 'email', 'password')}), |
||||||
|
(_('Personal info'), {'fields': ('first_name', 'last_name')}), |
||||||
|
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', |
||||||
|
'groups', 'user_permissions')}), |
||||||
|
(_('Important dates'), {'fields': ('last_login', 'date_joined')}), |
||||||
|
) |
||||||
|
add_fieldsets = ( |
||||||
|
(None, { |
||||||
|
'classes': ('wide',), |
||||||
|
'fields': ('username', 'email', 'password1', 'password2')} |
||||||
|
), |
||||||
|
) |
||||||
|
form = CustomUserChangeForm |
||||||
|
add_form = CustomUserCreationForm |
||||||
|
list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff') |
||||||
|
search_fields = ('username', 'email', 'first_name', 'last_name') |
||||||
|
ordering = ('email',) |
||||||
|
|
||||||
#admin.site.register(models.DokUser) |
admin.site.register(DokUser, CustomUserAdmin) |
||||||
|
|||||||
Loading…
Reference in new issue