views:

299

answers:

4

I have Apache setup to serve requests for http://www.mysite.com from this directory:

/var/www/html/www.mysite.com

The Django site is in /var/www/html/www.mysite.com/mysite.

I get this error when I make a request for /mysite/app/foo:

(big stack trace) AttributeError: 'module' object has no attribute 'common'

'myapp.common' is the first item listed after all the django apps (eg. 'django.contrib.admin') in INSTALLED_APPS in the settings.py file. If I change the order of modules listed, Django chokes on the first path of one of my applications that it encounters.

The Python import path seems to be correct, since it's finding mysite.settings:

<Location "/mysite/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
    PythonOption django.root /mysite
    PythonDebug On
    PythonPath "['/var/www/html/www.mysite.com'] + sys.path"
</Location>

What could be the problem? It's strange that it's complaining about 'common' when the actual list contains 'mysite.common':

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'mysite.common',
    ....

Is this a Django bug or do I have something misconfigured? Perhaps some external dependency needs to be added to the import path? It works OK with the Django development server.

+1  A: 

Does your mysite directory contain a __init__.py file? It should, to mark it as a package.

orip
Yes, and the "common" app's subdirectory should as well...
Gabriel Ross
unless it's "common.py" :)
orip
A: 

Yes, it does.

This does not appear to be an answer. This appears to be a clarification of your question. Please edit your question and delete this non-answer.
S.Lott
A: 

Is mysite.common a package stored under /var/www/html/www.mysite.com/mysite/common? If so try using common instead of mysite.common in INSTALLED_APPS.

Chris Hall
A: 

I'm guessing you're obscuring your actual module name intentionally, which is fine... but I got this error when I had named my Django site (mysite, in your case) with the same name as a Python module that exists elsewhere in sys.path.

For example, if you created a Django site called math, with an app called common inside of it, you'd get this error because the Python system math module doesn't contain an attribute or submodule named common.

You'll have to rename your Django site to not collide with the other module name.

UltraNurd