from django.utils.translation import gettext_lazy as _ from django.contrib import admin from django.contrib.auth.admin import UserAdmin as BaseUserAdmin from access.models import User from django.contrib.auth.models import Group admin.site.unregister(Group) @admin.register(User) class UserAdmin(BaseUserAdmin): search_fields = ["email", "name"] readonly_fields = ["id", "uuid", "created_at", "updated_at"] list_display = [ "email", "name", "gender", "birthdate", "avatar", "is_active", "is_admin", "is_staff", "created_at", ] list_filter = [ "is_active", "is_admin", "is_staff", "created_at", "updated_at", "gender", ] filter_horizontal = [] date_hierarchy = "created_at" ordering = ["-created_at"] add_fieldsets = ( ( _("Сведения"), { "fields": ["name", "email", "birthdate", "gender", "avatar"] }, ), ( _("Доступ"), {"fields": ["is_active", "is_admin", "is_staff"]}, ), ) fieldsets = ( ( _("Сведения"), { "fields": ["id", "uuid", "name", "email", "birthdate", "gender", "avatar"] }, ), ( _("Доступ"), {"fields": ["is_active", "is_admin","is_staff", "password"]}, ), (_("Даты"), {"fields": ["created_at", "updated_at"]}), ) class Media: pass