You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TeamFlash/sahara/main/admin.py

38 lines
1.4 KiB

from django.contrib import admin
6 months ago
from django.contrib.auth.admin import UserAdmin
from .models import User,ServiceRequest # Import your custom User model
6 months ago
class CustomUserAdmin(UserAdmin):
model = User
6 months ago
# Fields to display in the list view of the admin
list_display = ['email', 'first_name', 'last_name', 'is_staff', 'is_superuser', 'is_active']
6 months ago
# Fields to search in the admin
search_fields = ['email', 'first_name', 'last_name']
6 months ago
# Default ordering of records in the admin
ordering = ['email']
# Fieldsets for the add and change forms in the admin
fieldsets = (
(None, {'fields': ('email', 'password')}),
('Personal Info', {'fields': ('first_name', 'last_name')}),
('Permissions', {'fields': ('is_active', 'is_staff', 'is_superuser')}),
('Important Dates', {'fields': ('last_login',)}), # Remove 'date_joined' if it doesn't exist
)
# Fieldsets for the add form in the admin
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('email', 'first_name', 'last_name', 'password1', 'password2', 'is_staff', 'is_superuser', 'is_active'),
}),
)
# Filters for the list view in the admin
list_filter = ('is_staff', 'is_superuser', 'is_active')
# Register your custom User model with the custom UserAdmin class
admin.site.register(User, CustomUserAdmin)
admin.site.register(ServiceRequest)