Skip to content

Support geometry field references crossing foreign keys #7

@nnseva

Description

@nnseva

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions