Files
thrillwiki_django_no_react/location/admin.py
2024-11-03 17:47:26 +00:00

32 lines
1.1 KiB
Python

from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
from .models import Location
@admin.register(Location)
class LocationAdmin(admin.ModelAdmin):
list_display = ('name', 'location_type', 'city', 'state', 'country')
list_filter = ('location_type', 'country', 'state', 'city')
search_fields = ('name', 'street_address', 'city', 'state', 'country')
readonly_fields = ('created_at', 'updated_at')
fieldsets = (
('Basic Information', {
'fields': ('name', 'location_type')
}),
('Geographic Coordinates', {
'fields': ('latitude', 'longitude')
}),
('Address', {
'fields': ('street_address', 'city', 'state', 'country', 'postal_code')
}),
('Content Type', {
'fields': ('content_type', 'object_id')
}),
('Metadata', {
'fields': ('created_at', 'updated_at'),
'classes': ('collapse',)
})
)
def get_queryset(self, request):
return super().get_queryset(request).select_related('content_type')