Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support geometry field references crossing foreign keys #7

Open
nnseva opened this issue Apr 1, 2022 · 0 comments
Open

Support geometry field references crossing foreign keys #7

nnseva opened this issue Apr 1, 2022 · 0 comments

Comments

@nnseva
Copy link
Owner

nnseva commented Apr 1, 2022

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 nnseva changed the title Support geometry field references crossing foreign keys, like: Support geometry field references crossing foreign keys Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant