Answer the question
In order to leave comments, you need to log in
UWSGI and import errors?
Hello.
I have a django project. It is hosted on the standard uwsgi + nginx bundle.
The problem is this:
if the project is run as ./manage.py runserver or ./manage.py run_gunicorn (with the corresponding module installed), then everything rolls and works without errors. With UWSGI, absolutely inexplicable phenomena begin in the form of "cannot import name anything"
Usually this happens after adding (or changing) Django models and is treated either with lazy Relationships or import at the place of use.
The question is: why is there such a difference between Jung's validate and what happens in UWSGI.
Answer the question
In order to leave comments, you need to log in
The question is closed. There was a problem with django_debug_toolbar, it was importing crookedly and causing the import to fail. Shutdown and reconfiguration - helped.
Maybe the point is that after the changes you need to restart the uwsgi server? When you start the server with the ./manage.py command, all changes in the code are tracked and after writing it silently restarts. When launched via uwsgi, you have to do it manually.
This is where the answer to your question comes from - when working through manage.py, Dzhang utility methods are used, when working through uwsgi - wsgi methods.
I'm not sure, but maybe this reflection will help. Typically "cannot import name" errors occur when the paths are incorrect. The internal paths of a project are relative to the project itself. But does the uwsgi module itself know the path to the project?! In the module settings there is an option chdir , which changes to the directory you need before starting the module. It may not be listed for you. Or the pythonpath variable is set incorrectly .
For example, I start uwsgi with the help of supervisor (but it is possible without it) with the following command:
and the uwsgi.yaml settings file itself looks like this:
uwsgi:
uid: user_name
gid: user_group
socket: /tmp/uwsgi.sock
chmod-socket: 666
chdir: /opt/project_dir/
pythonpath: /opt/project_dir/project_name/
env: DJANGO_SETTINGS_MODULE=project_name.settings
module: project_name.wsgi
max-requests: 5000
buffer-size: 32768
post-buffering: 8192
enable-threads: 1
harakiri: 660
reload-mercy: 8
master: 1
no-orphans: 1
vacuum: 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question