0

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?

alexykot
  • 699
  • 1
  • 8
  • 21
  • see this question maybe: http://stackoverflow.com/questions/12839213/attributeerror-settings-object-has-no-attribute-root-urlconf – kender Apr 21 '13 at 14:22
  • nope, checked that already, doesn't seem to be linked to my problem AFAIU. – alexykot Apr 21 '13 at 14:29
  • do you have anything in `core/settings/__init__.py`? – alecxe Apr 21 '13 at 17:09
  • I found the problem, was my own fault - a while ago I've added some custom code in manage.py itself, that's why it was working through `runserver`. And in fact it was connected to settings splitting, so had to google and do it properly. Couldn't find how to delete this question, but it's answered now, thanks. – alexykot Apr 22 '13 at 17:59

0 Answers0