我正在尝试在我的应用程序库存中创建第一个测试。但是当它试图创建新数据库时,我收到以下错误:
@FormParam("test-param")
我的网站运行正常,但可能是因为我用较旧的django版本创建了它。目前我有django 1.8。我需要更换模型吗? 这就是我使用用户模型的方式:
$./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
Edit1 :我忘了写在这里我用google搜索错误消息,这些消息相关:1,2。然而,同步我的应用程序没有帮助。我尝试同步auth和类似的未迁移应用程序,没有运气。我应该逐个同步所有这些并检查它们是否有迁移?如果他们不这样做,我应该创建新的吗?
答案 0 :(得分:0)
您需要为模型WatchStock
创建迁移。