Skip to content

Region and Subregion model have no Geometry (area|location) - no way to query distance #183

Closed
@kiddhustle

Description

@kiddhustle

Checklist

  • I have verified that I am using a GIS-enabled database, such as PostGIS or Spatialite.
  • I have verified that that issue exists against the master branch of django-cities.
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • I have reduced the issue to the simplest possible case.
  • I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
from django.contrib.gis.db.models.functions import Distance
start_place = City.objects.filter(country__name='United Kingdom').get(name='London')

result = Region.objects.all().annotate(dist=Distance('location', start_place.location)).exclude(id=start_place.id).filter(name='Scotland').order_by('-dist')
or
```result = Region.objects.all().annotate(dist=Distance('location', start_place.location)).exclude(id=start_place.id).filter(name='Scotland').order_by('-dist')`

Expected behavior

To return the distance from Scotland region

Actual behavior

Following errors:

FieldError: Cannot resolve keyword 'location' into field. Choices are: alt_names, cities, code, country, country_id, id, name, name_std, postal_codes, slug, subregions
FieldError: Cannot resolve keyword 'area' into field. Choices are: alt_names, cities, code, country, country_id, id, name, name_std, postal_codes, slug, subregions

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions