django-rest-framework-gis
django-rest-framework-gis copied to clipboard
KeyError at /locationlist/ 'dwithin'
When I tried to use DistanceToPointFilter
to filter through distance, I got the issue that there is a KeyError about dwithin
.
models.py
class Location(models.Model):
user = models.ForeignKey('UserProfile', null=True, blank=True, on_delete=models.CASCADE)
address = models.CharField(max_length=255)
number = models.CharField(max_length=255)
city = models.CharField(max_length=100)
state = models.CharField(max_length=100)
zipcode = models.CharField(max_length=5)
# point = gis_models.PointField()
geometry = gis_models.GeometryField()
class Meta:
verbose_name = 'Location'
verbose_name_plural = 'Locations'
def __str__(self):
return self.geometry
serializers.py
class LocationSerializer(GeoFeatureModelSerializer):
class Meta:
model = Location
geo_field = 'geometry'
fields = "__all__"
views.py
class LocationListViewSet(viewsets.GenericViewSet, mixins.ListModelMixin):
queryset = Location.objects.all()
serializer_class = LocationSerializer
distance_filter_convert_meters = True
distance_filter_field = 'geometry'
filter_backends = (DistanceToPointFilter,)
Hi! I'd be happy to take up this