FAQ Database Discussion Community


Custom SQL for Geodjango on ForignKey

django,django-models,gis,postgis,geodjango
I have a following model: class UserProfile(models.Model): user = models.OneToOneField(User) location = models.PointField(blank=True, null=True, srid=CONSTANTS.SRID) objects = models.GeoManager() class Item(models.Model): owner = models.ForeignKey(UserProfile) objects = models.GeoManager() Now I need to sort the Items by distance to some point: p = Point(12.5807203, 50.1250706) Item.objects.all().distance(p, field='owner__location') But that throws me an error:...

Which Model Field to use in Django to store longitude and latitude values?

python,django,geodjango
I want to store my users location using longitude and latitude, at the moment this comes from Google Maps, but I will be using GeoDango and some point to work out distances between to points also. However, my first confusion is which field in Django I should be using to...

Getting geodjango query to return distance as an attribute?

python,django,geospatial,geodjango
Is there a way to get a query to return the distance from the point for each location? Right now I have Location.objects.filter(geometry__distance_lte=(pnt, D(mi=20))) but the rows don't have a distance attribute. How can I get the distance from pnt for each row that is returned?

installing GeoDjango on Heroku

django,heroku,geodjango
I am trying to build a webapp which uses GeoDjango. The app is to be hosted on Heroku, but I am facing issues in it. I am using this buildpack but then this error is coming. Figured out that this is happening because of Cedar 14 but I am not...

Django and GeoDjango database backend

mysql,django,spatial,geodjango
I am using a Django app with MySQL database backend and I want to implement GeoDjango I have to change backend to: django.contrib.gis.db.backends.mysql I don't know if that is simple as it?...