Advertisement
robertvari

Custom User Admin

Dec 17th, 2019
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. from django.contrib import admin
  2. from django.contrib.auth.admin import UserAdmin
  3.  
  4. from .models import CustomUser
  5.  
  6.  
  7. class CustomUserAdmin(UserAdmin):
  8.     list_display = ("full_name", "email", "location", "last_login", "is_admin", "is_staff")
  9.     search_fields = ("full_name", "email", "location")
  10.     readonly_fields = ("password", "date_joined", "last_login")
  11.     ordering = ("full_name",)
  12.  
  13.     filter_horizontal = ()
  14.     list_filter = ()
  15.     fieldsets = (("Login",
  16.                   {
  17.                       "fields": ("email",)
  18.                   }),
  19.                  ("Personal details",
  20.                   {
  21.                       "classes": ("wide",),
  22.                       "fields": ("profile_pic", "full_name", "location", "bio", ("linkedin", "facebook", "twitter", "instagram"))
  23.                   }),
  24.                  ("Social",
  25.                   {
  26.                       "classes": ("wide",),
  27.                       "fields": (("follows",),)
  28.                   })
  29.                  )
  30.  
  31.  
  32.     add_fieldsets = (
  33.         (None, ({"fields": ("email", "full_name", "password1", "password2")})),
  34.     )
  35.  
  36.  
  37. admin.site.register(CustomUser, CustomUserAdmin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement