Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

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.

share|improve this question

3 Answers 3

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

share|improve this answer
    
Yes, and the "common" app's subdirectory should as well... – Gabriel Ross Jan 22 '09 at 20:42
    
unless it's "common.py" :) – orip Jan 22 '09 at 21:50

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.