简体   繁体   中英

Django App works fine locally but fails on Heroku

I am trying to deploy this app https://bitbucket.org/hybird/creme_crm-1.2 on Heroku. I followed the guide https://devcenter.heroku.com/articles/django The app works fine on the local server using django dev server or gunicorn with "foreman start" but fails on Heroku with this error:

[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"

The error says you are missing a module : creme_core

When you deploy a project to heroku, heroku uses a pip freeze requirements file which contains all of the modules in your project. Heroku downloads all the modules in the requirements file while deploying your application.

Make sure you have a requirments.txt file (pip freeze file) : it's in the documentation under pip freeze here

The problem was that I was pushing to heroku from inside the application folder. Suppose my application is in the folder creme. I must create a folder containing the creme folder, requirements.txt and Procfile. The error was that I put requirements and Procfile inside the creme folder, it works on localhost but not on Heroku.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM