Closed StefanBrand closed 3 years ago
I created a custom View like this:
View
class PostGISFeatureViewWithManualVectorTileQuerySet(PostgisMVTView, DetailView): vector_tile_layer_name = "features" vector_tile_fields = ('name', ) def get(self, request, *args, **kwargs): self.vector_tile_queryset = Feature.objects.filter(date="2020-07-07") return BaseVectorTileView.get(self, request=request, z=kwargs.get('z'), x=kwargs.get('x'), y=kwargs.get('y'))
Then I tested the number of queries like this:
class VectorTileTestCase(VectorTileBaseTest): def test_num_queries_equals_one(self): self.maxDiff = None with self.assertNumQueries(1): self.client.get( reverse( 'feature-postgis-with-manual-vector-tile-queryset', args=(0, 0, 0) ) )
This test fails because if self.vector_tile_queryset evaluates any QuerySet. This is not desired.
if self.vector_tile_queryset
QuerySet
https://github.com/submarcos/django-vectortiles/blob/fb2ad8ca8ea9c4384a5325599c95f363ce9e89f9/vectortiles/mixins.py#L21-L22
My colleague (Thank you!) proposed a fix, that I will create a PR for.
I created a custom
View
like this:Then I tested the number of queries like this:
This test fails because
if self.vector_tile_queryset
evaluates anyQuerySet
. This is not desired.https://github.com/submarcos/django-vectortiles/blob/fb2ad8ca8ea9c4384a5325599c95f363ce9e89f9/vectortiles/mixins.py#L21-L22
My colleague (Thank you!) proposed a fix, that I will create a PR for.