django-leaflet-admin-list
django-leaflet-admin-list copied to clipboard
Support geometry field references crossing foreign keys
We need patches like the following to have a field crossing a reference:
class PassengersFilter(BoundingBoxFilter):
"""Filter customized by the calculated field"""
geometry_fields = ['location_point']
@admin.register(Passenger)
class SomeAdmin(LeafletGeoAdminMixin, LeafletAdminListMixin, admin.ModelAdmin):
list_filter = (
...
PassengersFilter,
)
geometry_fields = ['location_point']
def get_queryset(self, request):
ret = super().get_queryset(request).annotate(location_point=Centroid('location__point'))
return ret
def get_geojson_feature_verbose_name(self, request, name, o, queryset):
return _('Passenger Location')
It's probably useful to have them automatically only based on the geometry_fields definition.