【问题标题】:Django App works fine locally but fails on HerokuDjango App 在本地运行良好,但在 Heroku 上失败
【发布时间】:2012-09-26 19:54:25
【问题描述】:

我正在尝试在 Heroku 上部署此应用程序 https://bitbucket.org/hybird/creme_crm-1.2。 我跟着指南https://devcenter.heroku.com/articles/django 该应用程序使用 django 开发服务器或带有“工头启动”的 gunicorn 在本地服务器上运行良好,但在 Heroku 上失败并出现以下错误:

[INFO] Starting gunicorn 0.14.6
Starting gunicorn 0.14.6
[INFO] Listening at: http://0.0.0.0:16635 (2)
Listening at: http://0.0.0.0:16635 (2)
[INFO] Using worker: sync
Using worker: sync
[INFO] Booting worker with pid: 5
Booting worker with pid: 5
    response = view_func(request, *args, **kwargs)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/views/decorators/cache.py", line 79, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/auth/views.py", line 69, in login
    context_instance=RequestContext(request, current_app=current_app))
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/context.py", line 172, in __init__
    for processor in get_standard_processors() + processors:
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/context.py", line 150, in get_standard_processors
    raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))
ImproperlyConfigured: Error importing request processor module creme_core.context_processors: "No module named creme"

【问题讨论】:

    标签: django heroku


    【解决方案1】:

    错误提示您缺少一个模块:creme_core

    当您将项目部署到 heroku 时,heroku 使用 pip freeze 需求文件,其中包含项目中的所有模块。 Heroku 会在部署应用程序时下载需求文件中的所有模块。

    确保你有一个 requirments.txt 文件(pip freeze 文件):它在 pip freeze here 下的文档中

    【讨论】:

    • 我有一个 requirements.txt 文件,但是 creme_core 已经在我推送到 Heroku 的源代码中,它是 Web 应用程序的一部分。正如我所说,该应用程序在 localhost 上运行良好。
    • 经过一些研究,它看起来像是一个与您的要求无关的错误。它更多的是一些本地变量配置错误。具体来说,它看起来与位于设置文件中的上下文处理器变量有关
    【解决方案2】:

    问题是我从应用程序文件夹中推送到 heroku。 假设我的应用程序位于 creme 文件夹中。我必须创建一个包含 creme 文件夹、requirements.txt 和 Procfile 的文件夹。错误是我将需求和 Procfile 放在 creme 文件夹中,它适用于 localhost 但不适用于 Heroku。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-14
      • 2020-08-03
      • 1970-01-01
      • 2013-04-09
      • 2013-09-22
      • 1970-01-01
      • 2014-01-01
      • 2020-04-10
      相关资源
      最近更新 更多