簡體   English   中英

使用 Heroku 進行部署時,如何克服“'django_content_type' 不存在”錯誤?

[英]How can I get past this “'django_content_type' does not exist” error when deploying with Heroku?

我正在嘗試使用 Heroku 部署我的第一個真正的網站。 以前用一個超級簡單的網站成功部署過一次,但是這次好像卡住了。 我可以在本地正常運行該站點。

當我在 Heroku 上單擊 Deploy for Free 時,它​​成功地創建應用程序、配置環境和構建應用程序。 該錯誤來自 Run scripts & scale dynos 部分,說“部署后退出代碼不是 0”

我使用 Django 1.9.4 和cookiecutter-django來啟動我的項目。 我還在我的項目中添加了wagtail並用它制作了一些相當簡單的頁面。 如果您需要查看我的任何其他文件,請告訴我。 我對這個不知所措。

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "django_content_type" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...

                                                             ^



The above exception was the direct cause of the following exception:


Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/contenttypes/models.py", line 67, in get_for_model
    ct = self.get(app_label=opts.app_label, model=opts.model_name)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/manager.py", line 122, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/query.py", line 381, in get
    num = len(clone)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/query.py", line 240, in __len__
    self._fetch_all()
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/query.py", line 1074, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/query.py", line 52, in __iter__
    results = compiler.execute_sql()
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 848, in execute_sql
    cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "django_content_type" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...

                                                             ^



During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 398, in execute
    self.check()
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/checks/registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
    errors.extend(model.check(**kwargs))
  File "/app/.heroku/python/lib/python3.5/site-packages/wagtail/wagtailcore/models.py", line 572, in check
    if not issubclass(edit_handler.get_form_class(cls), WagtailAdminPageForm):
  File "/app/.heroku/python/lib/python3.5/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 294, in get_form_class
    formsets=cls.required_formsets(),
  File "/app/.heroku/python/lib/python3.5/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 240, in required_formsets
    formsets.update(handler_class.required_formsets())
  File "/app/.heroku/python/lib/python3.5/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 240, in required_formsets
    formsets.update(handler_class.required_formsets())
  File "/app/.heroku/python/lib/python3.5/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 603, in required_formsets
    'widgets': child_edit_handler_class.widget_overrides(),
  File "/app/.heroku/python/lib/python3.5/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 216, in widget_overrides
    widgets.update(handler_class.widget_overrides())
  File "/app/.heroku/python/lib/python3.5/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 216, in widget_overrides
    widgets.update(handler_class.widget_overrides())
  File "/app/.heroku/python/lib/python3.5/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 516, in widget_overrides
    content_type=cls.target_content_type(), can_choose_root=cls.can_choose_root)}
  File "/app/.heroku/python/lib/python3.5/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 543, in target_content_type
    cls._target_content_type = [ContentType.objects.get_for_model(target_model)]
  File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/contenttypes/models.py", line 80, in get_for_model
    "Error creating new content types. Please make sure contenttypes "
RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.

您可能需要使用以下命令運行遷移命令:

heroku run python manage.py migrate

如果您還沒有升級到 Wagtail 1.4.3,請嘗試升級 - 最新版本修復了一些與從頭啟動項目數據庫相關的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM