Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#12727 closed (invalid)

Error while doing syncdb with a GIS app

Reported by: asgrewal Owned by: nobody
Component: GIS Version: 1.2-alpha
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The following error occurs while doing syncdb when an app contains GIS information, in my case a simple model with a PointField member. I am using Postgresql with postgis. The same code works fine for django 1.1

(django-dev-sandbox)ajeet@virtual-ubuntu:~/projects/enroute2$ python syncdb
Traceback (most recent call last):
  File "", line 11, in <module>
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/core/management/", line 438, in execute_manager
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/core/management/", line 379, in execute
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/core/management/", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/core/management/", line 222, in execute
    output = self.handle(*args, **options)
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/core/management/", line 351, in handle
    return self.handle_noargs(**options)
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/core/management/commands/", line 78, in handle_noargs
    sql, references = connection.creation.sql_create_model(model,, seen_models)
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/db/backends/", line 50, in sql_create_model
    col_type = f.db_type(connection=self.connection)
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/db/models/fields/", line 28, in inner
    return func(*args, **kwargs)
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/db/models/fields/", line 28, in inner
    return func(*args, **kwargs)
  File "/home/ajeet/django-dev-sandbox/lib/python2.6/site-packages/django/contrib/gis/db/models/", line 200, in db_type
    return connection.ops.geo_db_type(self)
AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'

Change History (2)

comment:1 Changed 9 years ago by jbronn

Resolution: invalid
Status: newclosed

Due to the multi-db merge into trunk, in order to be backwards-compatible with 1.1.X settings, you'll need 'django.contrib.gis' in your INSTALLED_APPS setting to ensure that the spatial database backend (django.contrib.gis.db.backends.postgis) is used instead of the regular backend (django.db.backends.postgresql_psycopg2). You can also just upgrade your settings to use the new DATABASES syntax for configuring your database and explicitly specify the spatial backend:

    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'geodjango',
        'USER': 'myuser',

comment:2 Changed 7 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top