Django: wsgi import error mode with mysite.settings not found

Hi, I spent 2 days on this error. could not figure it out.

an 21 00:19:50 2011] [error] [client 127.0.0.1] ImportError: Could not import settings 'mysite.settings' (Is it on sys.path? Does it have syntax errors?): No module named settings

django.wsgi is located in / user / local / django / apache

import os, sys
sys.path.append('/usr/local/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

my django project named mysite: is located in / user / local / django / mysite / scr / (there are settings.py init.py here, etc.)

apache conf

Alias /media/ /usr/local/django/media
<Directory /usr/local/django/media>
Order deny,allow
Allow from all
</Directory>

<Directory /usr/local/django/apache/>
Order deny,allow
Allow from all
</Directory>



WSGIScriptAlias / /usr/local/django/apache/django.wsgi

I changed the mysite folder above with a resolution of 777 to avoid any resolution problems. and every time I restart the httpd service.

apache launches and finds django.wsig. but he cannot find the settings file specified in it.

and I will add the path to $ PATH manually and repeat it. it's over there. and I restart httpd. the path that I added disappeared ...

Does anyone know what is going on?

thank

+3
source share
3 answers

, , sys.path .

, , settings.py .../django/mysite/scr/, mysite.settings .

, mysite __init__.py, mysite.scr.settings

+2

settings.py /usr/local/django/mysite/scr/, , , :

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.scr.settings'
+3

, .

"runningerver"? , , ,

The INSTALLED APPS order may be important. For one of my projects, this error disappeared when I changed the order of installed applications.

The answers to this question that I asked a little back may be useful. How to stop receiving ImportError: failed to import "mofin.settings" settings when using django with wsgi?

+1
source

Source: https://habr.com/ru/post/1786842/


All Articles