Thursday, June 28, 2012

settings and constants on a reusable app

Hi,
I'm developing a reusable application and I'm having troubles with
constant values on settings.

Imagine that the reusable application comes with the following settings.py

# MY_APP/settings.py
from django.conf import settings
MY_CONSTANT = 'C1'
MY_OTHER_CONSTANT = 'C2'
MY_SETTING = getattr(settings, 'MY_SETTING', CONSTANT)


But for your project you want to override the default value of
MY_SETTING by MY_OTHER_CONSTANT. So you edit your project settings.py
and adds these two lines:

# Project settings.py
....
from MY_APP.settings import settings as my_app_settings
MY_SETTING = my_app_settings.MY_OTHER_SETTING


But this is going to fail because of the import order.

Is there any consistent way to handle this situation?

Thanks!
--
Marc

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment