cirlabs / django-project-template

A collection of development tasks and optimizations aimed at anyone doing news application development on tight deadlines in Django.
17 stars 10 forks source link

postgis is improperly configured in `common.py` #43

Closed aboutaaron closed 9 years ago

aboutaaron commented 9 years ago

Current:

db = 'postgis' if USE_POSTGIS else 'postgresql_psycopg2'
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.'+db, # Add 'postgresql_psycopg2', 'postgis', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'google_dmca_takedowns',
    }
}

Error:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/home/aaron/.anaconda/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/contrib/auth/models.py", line 40, in <module>
    class Permission(models.Model):
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/db/models/base.py", line 122, in __new__
    new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/db/models/base.py", line 297, in add_to_class
    value.contribute_to_class(cls, name)
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/db/models/options.py", line 166, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/db/__init__.py", line 40, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/db/utils.py", line 242, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/home/aaron/.anaconda/lib/python2.7/site-packages/django/db/utils.py", line 126, in load_backend
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgis' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
    u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: No module named postgis.base

Fix:

DATABASES = {
    'default': {
         'ENGINE': 'django.contrib.gis.db.backends.postgis',
     }
}