Manage.py works but wizard throws errors

This question is asked by Heroku and django.

When I run my application with the "python manage.py runningserver" command, the web server starts without error. Then I can find my visitor's home page localhost: 8000 in my browser. Fine.

When I launch my application using the "start wizard" command, the web server also starts without error. he reads

00:44:19 web.1  | started with pid 9736
00:44:19 web.1  | 2014-09-22 00:44:19 [9736] [INFO] Starting gunicorn 19.0.0
00:44:19 web.1  | 2014-09-22 00:44:19 [9736] [INFO] Listening at: http://0.0.0.0:5000 (9736)
00:44:19 web.1  | 2014-09-22 00:44:19 [9736] [INFO] Using worker: sync
00:44:19 web.1  | 2014-09-22 00:44:19 [9739] [INFO] Booting worker with pid: 9739

      

Tall. When I try to visit localhost: 5000 something goes wrong. The page displays "Internal Server Error". Yes. I look at the stack that the foreman produces and this is what I see:

00:45:22 web.1  |     respiter = self.wsgi(environ, resp.start_response)
00:45:22 web.1  |   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
00:45:22 web.1  |     self.load_middleware()
00:45:22 web.1  |   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/handlers/base.py", line 46, in load_middleware
00:45:22 web.1  |     for middleware_path in settings.MIDDLEWARE_CLASSES:
00:45:22 web.1  |   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/conf/__init__.py", line 54, in __getattr__
00:45:22 web.1  |     self._setup(name)
00:45:22 web.1  |   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/conf/__init__.py", line 49, in _setup
00:45:22 web.1  |     self._wrapped = Settings(settings_module)
00:45:22 web.1  |   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/sitepackages/django/conf/__init__.py", line 132, in __init__
00:45:22 web.1  |     % (self.SETTINGS_MODULE, e)
00:45:22 web.1  | ImportError: Could not import settings 'gettingstarted.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named 'dj_database_url'

      

dj_database_url did not import correctly. Weird. "Import dj_database_url" appears in the very top corner of my settings.py file.

If I activate my virtualenv and start python, I can run the "import dj_database_url" command. Also, when I start the server with manage.py, setup.py opens, so the import should work as well. So why use a wizard for this import?

Here is my wsgi.py:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gettingstarted.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

      

Thanks in advance for any help

+3


source to share


1 answer


Since it dj_database_url

is only installed in your virtual environment, make sure the foreman

environment is activated at startup ; otherwise, you will see an exception.

If you're going to deploy this to Heroku you won't have this problem because by default Heroku will install from your file requirements.txt

and thus your environment will have dj_database_url

and everything will work as expected.



I can also see that you are using Python 3.4 - if you don't have any special problems try using Python 2.7x as some libraries are still being ported to Python 3. You may encounter unexplained errors later, version incompatibilities.

+2


source







All Articles