Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- App accounts:
- 1. In forms.py we add:
- class MyHolidayUserChangeForm(auth_forms.UserChangeForm):
- class Meta(auth_forms.UserChangeForm.Meta):
- model = UserModel
- 2. In admin.py we add:
- from django.contrib import admin
- from django.contrib.auth import admin as auth_admin
- from my_holiday.accounts.forms import MyHolidayUserCreationForm, MyHolidayUserChangeForm
- UserModel = get_user_model()
- @admin.register(UserModel)
- class AppUserAdmin(auth_admin.UserAdmin):
- model = UserModel
- add_form = MyHolidayUserCreationForm
- form = MyHolidayUserChangeForm
- list_display = ('pk', 'email', 'is_staff', 'is_superuser')
- search_fields = ('email',)
- ordering = ('pk',)
- fieldsets = (
- (None, {'fields': ('email', 'password')}),
- ('Personal info', {'fields': ()}),
- ('Permissions', {'fields': ('is_active', 'is_staff', 'groups', 'user_permissions')}),
- ('Important dates', {'fields': ('last_login',)}),
- )
- add_fieldsets = (
- (
- None,
- {
- "classes": ("wide",),
- "fields": ("email", "password1", "password2"),
- },
- ),
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement