django-leaflet-admin-list icon indicating copy to clipboard operation
django-leaflet-admin-list copied to clipboard

Support geometry field references crossing foreign keys

Open nnseva opened this issue 3 years ago • 0 comments

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.

nnseva avatar Apr 01 '22 15:04 nnseva