Reputation:
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.
Upvotes: 0
Views: 593
Reputation: 1334
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.
Upvotes: 0
Reputation:
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
.
Upvotes: 0
Reputation: 75437
Does your mysite
directory contain a __init__.py
file? It should, to mark it as a package.
Upvotes: 1