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

GetCapabilities does not work with dotted model_attribute value #24

Open
jforsman opened this issue Apr 15, 2024 · 0 comments
Open

GetCapabilities does not work with dotted model_attribute value #24

jforsman opened this issue Apr 15, 2024 · 0 comments

Comments

@jforsman
Copy link

If a FeatureField has reference to a different model via FK reference, GetCapabilities query is not working.
eg.

FeatureField( "not_working", model_attribute="some_fk.field_name", abstract="does not work", )

Result from eg. http://localhost:8000/wfs/?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities
Now would be 500 internal server error.
Reason would be that "<feature_type> has no attribute field_name"

This is because FeatureType.get_bounding_box function uses self.get_query_set() that does not check any feature relations.

Suggested fix:
Change function FeatureType.get_bounding_box not to use get_query_set() as such but add a .only(self.geometry_field.name)

so line:
bbox = self.get_queryset().aggregate(a=Extent(geo_expression))["a"]
to:
bbox = self.get_queryset().only(self.geometry_field.name).aggregate(a=Extent(geo_expression))["a"]
or even:
bbox = self.queryset.only(self.geometry_field.name).aggregate(a=Extent(geo_expression))["a"]

I am not so familiar with the codebase that really not sure if this is the way to go here, maybe someone who actually is doing dev on this will do the actual fix in a different way. Atleast this way there would be no need for any prefetches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant