Advertisement
lamorfini

Untitled

May 19th, 2024
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. from django.contrib import admin
  2. from django.contrib.auth.admin import UserAdmin
  3.  
  4. from .forms import UserCreationFormAdmin, UserChangeFormAdmin
  5. from .models import User
  6.  
  7. @admin.register(User)
  8. class UserAdminPanel(UserAdmin):
  9.     add_form = UserCreationFormAdmin
  10.     form = UserChangeFormAdmin
  11.     model = User
  12.     list_display = ("email", "is_staff", "is_active",)
  13.     list_filter = ("email", "is_staff", "is_active",)
  14.     fieldsets = (
  15.         (None, {"fields": ('first_name', 'last_name', 'username', 'email', 'display_name', 'date_of_birth', 'sex', "password")}),
  16.         ("Permissions", {"fields": ("is_staff", "is_active", "is_superuser", "groups")}),
  17.     )
  18.     add_fieldsets = (
  19.         (None, {
  20.             "classes": ("wide",),
  21.             "fields": (
  22.                 "username", "email", "password1", "password2", "is_staff",
  23.                 "is_active", "groups", "user_permissions"
  24.             )}
  25.         ),
  26.     )
  27.     search_fields = ("email",)
  28.     ordering = ("email",)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement