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

KeyError at /locationlist/ 'dwithin' #185

Open
zshuang15 opened this issue Jan 17, 2019 · 1 comment
Open

KeyError at /locationlist/ 'dwithin' #185

zshuang15 opened this issue Jan 17, 2019 · 1 comment

Comments

@zshuang15
Copy link

zshuang15 commented Jan 17, 2019

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,)
@zshuang15 zshuang15 changed the title KeyError at /locationlist/ 'dwithin KeyError at /locationlist/ 'dwithin' Jan 17, 2019
@nemesifier nemesifier added the bug label Dec 9, 2019
@nemesifier nemesifier added this to Easy pickings in Hacktoberfest 2020 via automation Sep 30, 2020
@nemesifier nemesifier moved this from Easy pickings to Python | Django in Hacktoberfest 2020 Sep 30, 2020
@krishnaglodha
Copy link

Hi! I'd be happy to take up this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Hacktoberfest 2020
  
Python | Django
Development

No branches or pull requests

3 participants