I am trying to create first tests in my application stocks. But when It tries to create new database, I get following error:
$./manage.py test stocks --verbosity=3
/var/www/django/digrin27/wsgi/digrin/controller
/usr/local/lib/python2.7/dist-packages/bootstrap3_datetime/widgets.py:2: RemovedInDjango19Warning: The django.forms.util module has been renamed. Use django.forms.utils instead.
from django.forms.util import flatatt
WARNING:py.warnings:/usr/local/lib/python2.7/dist-packages/bootstrap3_datetime/widgets.py:2: RemovedInDjango19Warning: The django.forms.util module has been renamed. Use django.forms.utils instead.
from django.forms.util import flatatt
Creating test database for alias 'default' ('test_digrin')...
Got an error creating the test database: database "test_digrin" already exists
Type 'yes' if you would like to try deleting the test database 'test_digrin', or 'no' to cancel: yes
Destroying old test database 'default'...
Operations to perform:
Synchronize unmigrated apps: google, lib, staticfiles, debug_toolbar, twitter, faq, messages, broker, watcher, allauth, humanize, facebook, bootstrap3_datetime, haystack, bootstrap3, django_crontab
Apply all migrations: account, sessions, admin, sites, auth, contenttypes, portfolio, stocks, socialaccount
Synchronizing apps without migrations:
Running pre-migrate handlers for application auth
Running pre-migrate handlers for application contenttypes
Running pre-migrate handlers for application sessions
Running pre-migrate handlers for application sites
Running pre-migrate handlers for application django_crontab
Running pre-migrate handlers for application faq
Running pre-migrate handlers for application debug_toolbar
Running pre-migrate handlers for application haystack
Running pre-migrate handlers for application stocks
Running pre-migrate handlers for application broker
Running pre-migrate handlers for application portfolio
Running pre-migrate handlers for application watcher
Running pre-migrate handlers for application allauth
Running pre-migrate handlers for application account
Running pre-migrate handlers for application socialaccount
Running pre-migrate handlers for application facebook
Running pre-migrate handlers for application google
Running pre-migrate handlers for application twitter
Running pre-migrate handlers for application bootstrap3
Running pre-migrate handlers for application admin
Creating tables...
Creating table faq_topic
Creating table faq_question
Creating table broker_broker
Creating table watcher_watchstock
Running deferred SQL...
Traceback (most recent call last):
File "./manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 90, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 210, in run_tests
old_config = self.setup_databases()
File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 166, in setup_databases
**kwargs
File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 370, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/creation.py", line 368, in create_test_db
test_flush=True,
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 179, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 317, in sync_apps
cursor.execute(statement)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "auth_user" does not exist
My site works ok, but it might be because I have created it with older django version. Currently I have django 1.8. Do I have to change my models? This is how I use user model:
from django.contrib.auth.models import User
class WatchStock(models.Model):
user = models.ForeignKey(User)
...
Edit1: I forgot to write here I googled error message and these are relevant: 1, 2. However syncing my apps did not help. I tried to sync auth and similar unmigrated apps, no luck. Should I sync all of them one by one and check if they have migrations? If they do not, should I create new ones?