Note that there are some explanatory texts on larger screens.

plurals
  1. POGunicorn and django settings module
    text
    copied!<p>I've got a django app (<a href="https://github.com/wjdp/nt-tickets" rel="nofollow">https://github.com/wjdp/nt-tickets</a>) with the settings.py file in the root rather than in the nt-tickets subdirectory. This works fine as in wsgi.py and manage.py the following line has been altered to reflect the change:</p> <pre class="lang-py prettyprint-override"><code>os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") </code></pre> <p>I'm planning on using gunicorn for deployment and am running into an issue. Gunicorn ignores this line and assumes that the settings file will be <code>nt_tickets.settings</code>. I'm starting gunicorn like this:</p> <pre><code>gunicorn wsgi:application </code></pre> <p>and getting this error:</p> <pre><code>ImportError: Could not import settings 'nt_tickets.settings' (Is it on sys.path?): No module named nt_tickets.settings </code></pre> <p>I have found that putting <code>--settings "settings"</code> on the end of the command fixes the issue, but why am I having to do this? Surely the enviroment variable set in wsgi.py should suffice? This might seem petty, I'm trying to not repeat myself.</p> <hr> <p>Full trace:</p> <pre><code>2013-07-10 01:12:12 [29417] [ERROR] Error handling request Traceback (most recent call last): File "/home/will/env/nt_tickets/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 126, in handle_request respiter = self.wsgi(environ, resp.start_response) File "/home/will/env/nt_tickets/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__ self.load_middleware() File "/home/will/env/nt_tickets/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware for middleware_path in settings.MIDDLEWARE_CLASSES: File "/home/will/env/nt_tickets/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__ self._setup(name) File "/home/will/env/nt_tickets/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in _setup self._wrapped = Settings(settings_module) File "/home/will/env/nt_tickets/local/lib/python2.7/site-packages/django/conf/__init__.py", line 134, in __init__ raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'nt_tickets.settings' (Is it on sys.path?): No module named nt_tickets.settings </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload