Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding (not just overriding) settings should work too #1

Open
ghost opened this issue Dec 17, 2010 · 6 comments
Open

adding (not just overriding) settings should work too #1

ghost opened this issue Dec 17, 2010 · 6 comments

Comments

@ghost
Copy link

ghost commented Dec 17, 2010

It would be nice if things like INSTALLED_APPS += ('django-extensions',) would work with settingsdev and/or settingslocal respectively.

Of course this isn't just true for INSTALLED_APPS but should work in general. For example, things like this should work:
INTERNAL_IPS = ('127.0.0.1',)
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
INSTALLED_APPS += ('debug_toolbar',)

@robmadole
Copy link
Owner

You know I've ran into this too. It's because those are tuples and immutable. I'll see if I can come up with something that makes sense to include in this project. You have any ideas? This is ugly but functional (I think, haven't tried it)

INSTALLED_APPS = list(INSTALLED_APPS) + ['debug_toolbar']

@ghost
Copy link
Author

ghost commented Jan 7, 2011

A solution might be to work with exec() and compile() to load a series of settings files in order, where each file has full access to settings from previously-loaded files, to update, modify, etc.

http://code.djangoproject.com/wiki/SplitSettings#UsingalistofconffilesTransifex

@robmadole
Copy link
Owner

Thanks, I'll check this out.

@ghost
Copy link
Author

ghost commented Jan 8, 2011

I am now using INSTALLED_APPS += ('django_extensions',) from settingsdev.py by putting
exec(compile(open(os.path.join(os.path.dirname(file), 'settingsdev.py')).read(), "settingsdev.py", 'exec'))
into settings.py. This of course only works if
import settingsdev
api.collect(settingsdev)
is not used. I guess now we only need to make django-sunset use exec() implicitly for settingsdev.py, settingslocal.py, and everything in deployments/ etc.

@robmadole
Copy link
Owner

Wow, that does get pretty hairy.

Try this before we get too crazy with things.

In settingsdev or settingslocal:

import settingsbase
INSTALLED_APPS = list(settingsbase.INSTALLED_APPS) + [
    'debug_toolbar']

I would hate to get complex with this as long as there is a simple solution that accomplishes the same goal.

@robmadole
Copy link
Owner

Hey sunoano, is this issue resolved? I was going to close it out if you've worked around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant