from django.contrib import admin from django.contrib.auth.admin import UserAdmin from .models import User class AdminUser(UserAdmin): list_display = ["email", "first_name", "last_name", "role", "is_active", "created"] fieldsets = ( ( None, { "fields": ( "first_name", "last_name", "mobile", "email", "password", ) }, ), ( "Permissions", { "fields": ( "role", "is_active", "is_staff", "is_superuser", "user_permissions", ) }, ), ) add_fieldsets = ( (None, {"classes": ("wide",), "fields": ("email", "password1", "password2")}), ) list_filter = ("role", "is_active") search_fields = ("email", "first_name", "last_name") ordering = ("email",) filter_horizontal = ( "groups", "user_permissions", ) admin.site.register(User, AdminUser) # admin.site.unregister(Group)