My OSQA project doesn't seem to be retaining the project settings from the root of the project. It was working fine with version r1059, but when I updated to r1130 I started getting getting an error:

AttributeError: 'Settings' object has no attribute 'MODULE_LIST'
I know that the settings are being read at startup because I put a breakpoint in the settings file and it's triggered at boot.

However, when I try to import the settings into a file thusly:

from django.conf import settings

The settings in the project root don't load.

I'm getting the following error:
AttributeError: 'Settings' object has no attribute 'MODULE_LIST'

So I tried to step through the code with IPDB debugger:

> /Users/Bryan/work/osqa/forum/modules/__init__.py(12)get_modules_script()  
     11     import ipdb; ipdb.set_trace()  
---> 12     for m in settings.MODULE_LIST:  
     13         if hasattr(m, script_name):

ipdb> settings.MODULE_LIST  
*** AttributeError: 'Settings' object has no attribute 'MODULE_LIST'  
ipdb> import os  
ipdb> os.environ['DJANGO_SETTINGS_MODULE']  
'settings'  
ipdb> import settings  
ipdb> settings.MODULE_LIST  
[<module 'forum_modules.akismet' from '/Users/Bryan/work/osqa/forum_modules/akismet/__init__.pyc'>, <module 'forum_modules.default_badges' from '/Users/Bryan/work/osqa/forum_modules/default_badges/__init__.pyc'>, <module 'forum_modules.exporter' from ...snipsnip...]

Here is the full traceback:
Traceback (most recent call last):

  File "/usr/local/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/core/servers/basehttp.py", line 283, in run  
    self.result = application(self.environ, self.start_response)

File "/usr/local/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/contrib/staticfiles/handlers.py", line 68, in call
return self.application(environ, start_response)

File "/usr/local/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/core/handlers/wsgi.py", line 250, in call
self.load_middleware()

File "/usr/local/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/core/handlers/base.py", line 45, in load_middleware
mod = import_module(mw_module)

File "/usr/local/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/utils/importlib.py", line 35, in import_module
import(name)

File "/Users/Bryan/work/osqa/forum/middleware/extended_user.py", line 3, in <module>
from forum.models.user import AnonymousUser

File "/Users/Bryan/work/osqa/forum/models/init.py", line 39, in <module>
for k, v in get_modules_script_classes('models', models.Model).items():

File "/Users/Bryan/work/osqa/forum/modules/init.py", line 44, in get_modules_script_classes
scripts = get_modules_script(script_name)

File "/Users/Bryan/work/osqa/forum/modules/init.py", line 12, in get_modules_script
for m in settings.MODULE_LIST:

File "/usr/local/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/utils/functional.py", line 277, in getattr
return getattr(self._wrapped, name)

AttributeError: 'Settings' object has no attribute 'MODULE_LIST'

Why would this Django project not be able to access it's settings?

asked 29 Jul '11, 11:49

mrB's gravatar image

mrB
56349
accept rate: 0%

edited 29 Jul '11, 16:53


Try doing something like this:

from django.conf import settings as django_settings
print django_settings.MODULE_LIST

IMO your issue has to do with a conflict between forum.settings and django.conf.settings.

link

answered 30 Jul '11, 12:46

Jordan's gravatar image

Jordan ♦♦
3.1k618
accept rate: 38%

That did work. What was strange was that I would only get the error intermittently.

(01 Aug '11, 13:24) mrB

That did not work with me. I got the problem with gunicorn, but not with ./manage.py runserver...

(22 Aug '11, 08:32) nico91
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×30
×4
×1

Asked: 29 Jul '11, 11:49

Seen: 717 times

Last updated: 22 Aug '11, 08:32

powered by OSQA