Skip to content

Commit

Permalink
fix regression due to GIS import for django-filter #821
Browse files Browse the repository at this point in the history
thx to @mdellweg for preparing the fix (closes #820)
  • Loading branch information
tfranzel committed Sep 26, 2022
1 parent 9251d2d commit f6517d0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drf_spectacular/contrib/django_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,15 @@ def _get_schema_from_model_field(self, auto_schema, filter_field, model):
model_field = qs.query.annotations[filter_field.field_name].field
return auto_schema._map_model_field(model_field, direction=None)

def _is_gis(self, field):
@classmethod
def _is_gis(cls, field):
if not getattr(cls, '_has_gis', True):
return False
try:
from django.contrib.gis.db.models import GeometryField
from rest_framework_gis.filters import GeometryFilter

return isinstance(field, (GeometryField, GeometryFilter))
except ImportError:
except: # noqa
cls._has_gis = False
return False

0 comments on commit f6517d0

Please sign in to comment.