首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Django中与Oscar同步Postgres的编程错误

问Django中与Oscar同步Postgres的编程错误
EN

Stack Overflow用户
提问于 2015-07-10 23:05:05
回答 2查看 1K关注 0票数 2

我正在遵循奥斯卡教程(started.html),并试图让海斯塔克与Solr一起工作。我已经设置了postgres。我在Cloud9上跑。我试着运行"$ python noinput“,这最终会在运行迁移时被杀死.

代码语言:javascript
复制
/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

我还试着在没有输入的情况下运行这个程序

代码语言:javascript
复制
/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

如果我试图运行服务器,它会声明DB没有同步.当我试图加载页面时,我得到了这个.

代码语言:javascript
复制
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..。因为一些奇怪的原因,它不是同步的。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-07-10 23:43:13

删除数据库,删除迁移,然后运行syncdb或任意生成。也许这会有帮助。如果它不工作,那么请给我看你的模型文件。

票数 2
EN

Stack Overflow用户

发布于 2015-09-23 13:29:51

很大程度上是因为,在奥斯卡我猜你增加了

代码语言:javascript
复制
INSTALLED_APPS = [] + get_core_apps(['app.promotions'])

其中app是您的应用程序。奥斯卡的主页是在促销中写的。平台的模型不包括在内。您可以通过在__init__.py中导入组件来解决这一问题,但需要的除外。

app/promotions/__init__.py应该包含from oscar.apps.promotions import *

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31351611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档