geodjango

Getting 'DatabaseOperations' object has no attribute 'geo_db_type' error when doing a syncdb

牧云@^-^@ 提交于 2019-11-27 07:56:48
I'm attempting to run heroku run python manage.py syncdb on my GeoDjango app on Heroku, but I get the following error: AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type' All of my research has yielded the same solution: make sure to use django.contrib.gis.db.backends.postgis as the database engine. Funny thing is that I'm already doing this (and I also have django.contrib.gis in INSTALLED_APPS ): settings.py DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': '...', 'HOST': '...', 'PORT': ..., 'USER': '...', 'PASSWORD': '...' } }

How to access a geometry (point) field in PostGIS database from Django?

谁说我不能喝 提交于 2019-11-27 07:17:17
问题 In my project I am using PostgreSQL/PostGIS as the database and Django with django.contrib.gis configured. The existing table pois contains geospatial point data. Here is a excerpt from the SQL create statement: CREATE TABLE pois ( ogc_fid serial NOT NULL, the_geom geometry(Point,900914), name character varying(254), -- ... I generated the Django model with the following command: $ python manage.py inspectdb The generated model looks like this: from django.contrib.gis.db import models class

GeoDjango on Windows: “Could not find the GDAL library” / “OSError: [WinError 126] The specified module could not be found”

孤街浪徒 提交于 2019-11-27 04:41:33
I've been trying to setup my windows computer such that I can have a local postgreSQL with PostGIS extension. With this installed I hope to be able to create a project with geodjango locally before putting it in the cloud. I have been working with Django for a little while now on my local machine with the SQLite DB, but since the next project will partly be based on coordinate based data I wanted to setup the right environment. Import note: I've installed mini-conda to run in a seperate environment. I do activate this environment "development" when I work though I've tried to follow most of

How to make/use a custom database function in Django

谁说我不能喝 提交于 2019-11-27 03:37:49
问题 Prologue: This is a question arising often in SO: Equivalent of PostGIS ST_MakeValid in Django GEOS Geodjango: How to Buffer From Point Get random point from django PolygonField Django custom for complex Func (sql function) and can be applied to the above as well as in the following: Django F expression on datetime objects I wanted to compose an example on SO Documentation but since it got shut down on August 8, 2017, I will follow the suggestion of this widely upvoted and discussed meta

How to debug: Internal Error current transaction is aborted, commands ignored until end of transaction block

旧街凉风 提交于 2019-11-27 00:47:22
问题 Hi Stackoverflow people, I do my first steps with GeoDjango and I am looking for better options to check faulty sql statements. So far, I simply wanted to safe a lng+lat point in my postgresql table. The model is defined with: geolocation = models.PointField(_('Geo Location'), geography=True, null = True, blank = True, help_text=_('Geolocation with Longitude and Latitude')) objects = models.GeoManager() In my view, I try to execute the following command savedProject.geolocation = GEOSGeometry

Django sort by distance

孤人 提交于 2019-11-27 00:47:16
I have the following model: class Vacancy(models.Model): lat = models.FloatField('Latitude', blank=True) lng = models.FloatField('Longitude', blank=True) How should I make a query to sort by distance (distance is infinity)? Working on PosgreSQL, GeoDjango if it is required. cem First of all, it is better to make a point field instead of making lat and lnt separated: from django.contrib.gis.db import models location = models.PointField(null=False, blank=False, srid=4326, verbose_name="Location") Then, you can filter it like that: from django.contrib.gis.geos import * from django.contrib.gis

How do I convert kilometres to degrees in Geodjango/GEOS?

偶尔善良 提交于 2019-11-26 16:43:40
问题 I'm using the "buffer" method from the GEOS API to create a circle based on a point and a radius in GeoDjango, according to this answer: GeoDjango: How to create a circle based on point and radius As one commenter noted, you'll have to convert the radius in km to degrees... but how? I guess it's a quick formula but it's greek to me. I'd be grateful for any pointers. 回答1: The answer may depend upon location on earth. Near the equator, 1km is going to equal roughly 0.008 degrees (1 km / 40,000

Getting 'DatabaseOperations' object has no attribute 'geo_db_type' error when doing a syncdb

跟風遠走 提交于 2019-11-26 13:55:52
问题 I'm attempting to run heroku run python manage.py syncdb on my GeoDjango app on Heroku, but I get the following error: AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type' All of my research has yielded the same solution: make sure to use django.contrib.gis.db.backends.postgis as the database engine. Funny thing is that I'm already doing this (and I also have django.contrib.gis in INSTALLED_APPS ): settings.py DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db