Skip to content

Fix gis contrib geometry resolution when using different source (ref #989) - #1428

Open
submarcos wants to merge 5 commits into
tfranzel:masterfrom
submarcos:fix/contrib-gis-different-source
Open

Fix gis contrib geometry resolution when using different source (ref #989)#1428
submarcos wants to merge 5 commits into
tfranzel:masterfrom
submarcos:fix/contrib-gis-different-source

Conversation

@submarcos

@submarcos submarcos commented Jun 17, 2025

Copy link
Copy Markdown

Try to implement bugfix to #989

@submarcos submarcos changed the title Fix gis contrib geometry resokution when using different source (ref #989) Fix gis contrib geometry resolution when using different source (ref #989) Jun 17, 2025
@submarcos
submarcos marked this pull request as draft June 17, 2025 08:22
@submarcos
submarcos marked this pull request as ready for review November 17, 2025 15:24
@submarcos

Copy link
Copy Markdown
Author

@tfranzel Hi. Can you take a look at this ?

@submarcos

Copy link
Copy Markdown
Author

@tfranzel Hi. I'm blocked because drf-spectacular doesnt work with django.contrib.gis in some cases describe in #989. Can you take a look at this PR to fix and release ? thank you very much

Copilot AI review requested due to automatic review settings April 8, 2026 09:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #989 by fixing how GeoFeatureModelSerializer’s geo_field is resolved when the serializer field’s source does not directly match a model field name (e.g., source="aoi.geometry"), preventing KeyError during schema generation.

Changes:

  • Update GIS contrib schema generation to resolve geometry model fields via follow_field_source(...) using the serializer field’s source path.
  • Add a regression test case covering a GeoFeatureModelSerializer whose geo_field points to a serializer field with a different source.
  • Update the expected OpenAPI snapshot to include the new test route/schema.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
drf_spectacular/contrib/rest_framework_gis.py Fixes geometry model-field resolution by following the serializer field’s source path.
tests/contrib/test_rest_framework_gis.py Adds a new GeoFeature serializer scenario to exercise “geo_field name != model field name”.
tests/contrib/test_rest_framework_gis.yml Updates expected schema snapshot for the new endpoint/component.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/contrib/test_rest_framework_gis.py
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

Successfully merging this pull request may close these issues.

2 participants