3

I am trying to run django's test suite for my application with two databases: one using postgres and the other using POSTGIS. Here is my DATABASES configuration:

'default': {
       'ENGINE': 'django.db.backends.postgresql_psycopg2',
         ...},
'POSTGIS': {
         'ENGINE': 'django.contrib.gis.db.backends.postgis',
         ...}

When I run python manage.py test app I am prompted to delete an old test database, and when I say yes I get the following error:

Destroying old test database for alias 'default'...
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/test/runner.py", line 532, in run_tests
    old_config = self.setup_databases()
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/test/runner.py", line 482, in setup_databases
    self.parallel, **kwargs
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/test/runner.py", line 726, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 70, in create_test_db
    run_syncdb=True,
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/__init__.py", line 119, in call_command
    return command.execute(*args, **defaults)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 172, in handle
    self.sync_apps(connection, executor.loader.unmigrated_apps)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 285, in sync_apps
    editor.create_model(model)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 235, in create_model
    definition, extra_params = self.column_sql(model, field)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 134, in column_sql
    db_params = field.db_parameters(connection=self.connection)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 636, in db_parameters
    type_string = self.db_type(connection)
  File "/home/ubuntu/yes/lib/python2.7/site-packages/django/contrib/gis/db/models/fields.py", line 120, in db_type
    return connection.ops.geo_db_type(self)
AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'
Jake
  • 165
  • 8

1 Answers1

0
  1. Which version of Django are you using?
  2. When you made the database changes, prior to anything else, did you use the appropriate command to update the databases and relationships to them, i.e., syncdb or migrate?

Answering those two questions will help diagnose the problem. Thanks!

  • I'm using django 1.9, and I'm not sure exactly what your second question means. The POSTGRES database has been kept updated via django's migration layer. This isn't necessary for the POSTGIS database, which contains geographic models. There is no relationship between these two databases that django would know about. – Jake Feb 27 '16 at 20:14
  • It turns out I misunderstood your question and misread it. My initial thought was that it had to do with the settings.py file, the way that you were configuring your databases, etc. A little googling showed me that I was way off, and that it relates to [unit testing properties](http://stackoverflow.com/questions/26471389/django-cant-destroy-and-create-test-databases-properly). What happened when you tried what happened here? Did you make any system wide changes to your PostgreSQL? – Dheeraj Chand Feb 29 '16 at 04:13
  • That looks like it was a problem with mysql. I haven't make any changes to Postgres – Jake Mar 01 '16 at 23:15