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

rest_framework_gis support doesn't work if source points to a relationship #813

Closed
AndrewGuenther opened this issue Sep 22, 2022 · 3 comments · Fixed by #815
Closed

rest_framework_gis support doesn't work if source points to a relationship #813

AndrewGuenther opened this issue Sep 22, 2022 · 3 comments · Fixed by #815
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@AndrewGuenther
Copy link

Describe the bug
If I put a GeometryField on a serializer that has a source like geo.feature, the rest_framework_gis extension can't walk that relationship and defaults to string type.

To Reproduce
Here's a code example:

class AssetSerializer(serializers.ModelSerializer):
    aoi = GeometryField(source="aoi.geometry")

Expected behavior
I would expect that the relationship specified in source would be walked properly to identify the field type of geometry

@AndrewGuenther
Copy link
Author

https://github.com/tfranzel/drf-spectacular/blob/master/drf_spectacular/contrib/rest_framework_gis.py#L213

This line is the culprit. It does a naive field lookup which can't walk relationships.

tfranzel added a commit that referenced this issue Sep 22, 2022
@tfranzel tfranzel added bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending labels Sep 22, 2022
@tfranzel
Copy link
Owner

Hey @AndrewGuenther, good catch. could you try out #815 if that solves your issue?

@AndrewGuenther
Copy link
Author

I'm going to be on other projects through the end of this week, so I'll circle back and test this on Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants