python - 在 Django 中将 Postgres 与 Oscar 同步时出现编程错误

标签 python django ubuntu postgresql-9.1 django-oscar

我正在关注 OSCAR 教程 ( http://django-oscar.readthedocs.org/en/latest/internals/getting_started.html ),并尝试让 Haystack 与 Solr 一起使用。我已经设置了postgres。我在 Cloud9 上运行。我尝试运行“$ python manage.pysyncdb --noinput”这最终在运行迁移时被杀死...

/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/haystack/utils/__init__.py:12: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
  from django.utils import importlib

/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/oscar/apps/catalogue/abstract_models.py:20: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes.
  from django.contrib.contenttypes.generic import GenericForeignKey

/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py:24: RemovedInDjango19Warning: The syncdb command will be removed in Django 1.9
  warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning)

Operations to perform:
  Synchronize unmigrated apps: reports_dashboard, offers_dashboard, treebeard, communications_dashboard, reviews_dashboard, pages_dashboard, shipping_dashboard, haystack, promotions_dashboard, checkout, thumbnail, vouchers_dashboard, django_tables2, partners_dashboard, staticfiles, oscar, compressor, catalogue_dashboard, users_dashboard, search, messages, widget_tweaks, dashboard, ranges_dashboard, orders_dashboard
  Apply all migrations: customer, promotions, shipping, wishlists, offer, admin, sessions, contenttypes, auth, payment, reviews, analytics, catalogue, flatpages, sites, address, basket, partner, order, voucher
Synchronizing apps without migrations:
  Creating tables...
    Creating table thumbnail_kvstore
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states...Killed

我也尝试过在没有 --noinput 的情况下运行它

/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/haystack/utils/__init__.py:12: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
  from django.utils import importlib

/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/oscar/apps/catalogue/abstract_models.py:20: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes.
  from django.contrib.contenttypes.generic import GenericForeignKey

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 93, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 19, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 47, in __init__
    self.build_graph()
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 182, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
    self.ensure_schema()
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 49, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 162, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 135, in _cursor
    self.ensure_connection()
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
    self.connect()
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
    self.connect()
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 119, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 176, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: FATAL:  database "oscar_vagrant" does not exist

如果我尝试运行服务器,它会指出数据库未同步...当我尝试加载页面时,我得到这个...

ProgrammingError at /
relation "promotions_pagepromotion" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "promotion...
                                                             ^
Request Method: GET
Request URL:    https://love-benbuehne.c9.io/
Django Version: 1.8.3
Exception Type: ProgrammingError
Exception Value:    
relation "promotions_pagepromotion" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "promotion...
                                                             ^
Exception Location: /home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages/django/db/backends/utils.py in execute, line 64
Python Executable:  /home/ubuntu/workspace/oscar/bin/python
Python Version: 2.7.6
Python Path:    
['/home/ubuntu/workspace',
 '/home/ubuntu/workspace',
 '/home/ubuntu/lib/python/site-packages',
 '/home/ubuntu/workspace/oscar/lib/python2.7',
 '/home/ubuntu/workspace/oscar/lib/python2.7/plat-x86_64-linux-gnu',
 '/home/ubuntu/workspace/oscar/lib/python2.7/lib-tk',
 '/home/ubuntu/workspace/oscar/lib/python2.7/lib-old',
 '/home/ubuntu/workspace/oscar/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/home/ubuntu/workspace/oscar/local/lib/python2.7/site-packages']
Server time:    Fri, 10 Jul 2015 22:54:01 +0000

我有点困惑这意味着什么。似乎我在同步数据库时遇到了问题......而且似乎只是出现了某种超出我能力范围的错误。我什至不确定可以将哪些文件复制到此处会有帮助。据我所知,Django 正在访问 postgres...并且由于某些奇怪的原因它没有同步。

最佳答案

删除您的数据库,删除您的迁移,然后根据需要运行syncdb或makemigrations。也许这会有所帮助。 如果它不起作用,请向我展示您的模型文件。

关于python - 在 Django 中将 Postgres 与 Oscar 同步时出现编程错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31351611/

相关文章:

python - 类型错误 : tuple indices must be integers, 不是 str Python/django

python - 在 flask 模板 jinja2 中显示循环

python - Tkinter 打开两个窗口

python - 子进程无法捕获标准输出

python - 将函数从我的 django 方法中移出

python - Django 中 Slug 字段的优势或好处是什么?

ruby - 如何运行显示一些信息的 ruby​​ shell 脚本,然后要求输入并进入后台?

c++ - 自由人 : Unable to compile the Java API on Ubuntu

ubuntu - 我如何设置nginx每次都保持询问身份验证

python - 最Pythonic 的Tic-Tac-Toe 游戏板表示?