from django.contrib import admin from django.contrib.gis.admin import OSMGeoAdmin from birds.models import BirdSighting, BirdAudio, BirdClass, Bird from photos.forms import GalleryForm from utils.util import get_latlon class BirdClassAdmin(admin.ModelAdmin): list_display = ('common_name', 'scientific_name',) class BirdAudioAdmin(admin.ModelAdmin): list_display = ('bird', 'recorder',) class BirdAdmin(admin.ModelAdmin): list_display = ('pk', 'common_name', 'scientific_name', 'code', 'bird_class') list_filter = ('bird_class',) class GalleryFormPlus(GalleryForm): def __init__(self, *args, **kwargs): super(GalleryFormPlus, self).__init__(*args, **kwargs) self.base_fields['seen_by'].widget = CustomSelectMultiple() class BirdSightingAdmin(OSMGeoAdmin): form = GalleryFormPlus list_filter = ( ) list_display = ('bird', 'location') list_filter = ('seen_by',('location', admin.RelatedOnlyFieldListFilter),) fieldsets = ( ('Sighting', { 'fields': ( 'bird', 'point', 'date', 'seen_by', 'images', 'audio', ), 'classes': ( 'show', 'extrapretty', 'wide' ) } ), ) # options for OSM map Using custom ESRI topo map lat, lon = get_latlon() print(lat, lon) default_lon = lon default_lat = lat default_zoom = 13 units = True scrollable = False map_width = 700 map_height = 425 map_template = 'gis/admin/osm.html' openlayers_url = '/static/admin/js/OpenLayers.js' admin.site.register(BirdSighting, BirdSightingAdmin) admin.site.register(BirdClass, BirdClassAdmin) admin.site.register(BirdAudio, BirdAudioAdmin) admin.site.register(Bird, BirdAdmin)