I'm setting up django project in prodiction via mod_wsgi.
And the problem is that wsgi application fails with error AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'
, and I can't get why. When I run the same project via ./manage.py runserver
it works fine.
Project structure:
/var/www/python/projectname.org/projectname
./core/
./core/wsgi.py
./core/settings/
./__init__.py
./django.py
./extensions.py
./secrets.py
./server.py
./project.py
./app1
./app2
./templates
./static
...
Yes, usual Django settings file is split into several. This works perfectly fine in dev env, no idea if this is related to the problem I have with WSGI production env.
in console in python I can import projectname.core.settings
easily, but it also doesn't have the ROOT_URLCONF
inside.
wsgi.py:
import os
import sys
sys.path.append('/var/www/python/projectname.org')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projectname.core.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
apache virtualhost conf:
<VirtualHost *:80>
ServerAdmin alex@projectname.org
ServerName projectname.org
DocumentRoot /var/www/python/projectname.org/projectname/core
WSGIScriptAlias / /var/www/python/projectname.org/projectname/core/wsgi.py
<Directory /var/www/python/projectname.org/projectname>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
...
</VirtualHost>
When I try importing projectname.core.settings
in the console - import works fine, but I also cannot access ROOT_URLCONF
. Obviously this is related, but why then it works via runserver
? And how do I make it work via wsgi or console?