On Fri, 21 Jun 2013 04:38:33 -0700 (PDT) [email protected] wrote: > > I don't really want the settings to be adjusted at runtime, I would like > my application to reset some django "core" settings like the > MIDDLEWARE_CLASSES during the project configuration, once for all. > It is just to ease the deployment of the project and because the > applications knows which settings it needs. > > But if as you said settings are immutable then I'm doing it wrong, a > management command would be a better place to do this settings.
Sounds like you want to modify settings during deployment; a tool like django-buildout is maybe what you are after https://github.com/bchhun/django-buildout > > > Thank you for your answer > > Le jeudi 20 juin 2013 17:00:19 UTC+2, Jacky Tian a écrit : > > > > Django settings are meant to be immutable, so your issues might be > > stemming from the way you're changing settings at runtime. Most Django > > projects that need to adjust settings at runtime do so by keeping the > > mutable settings in the database (e.g. a separate app in the project), > > so that's an approach you could try. > > > > On Thursday, June 20, 2013 5:32:31 AM UTC-4, [email protected] wrote: > >> > >> Hello all, > >> > >> I want to have an application settings modifying the project settings > >> but it doesn't seems to work. > >> > >> For development purpose I need to authenticate users against my > >> application database. In Production > >> the authentication is done by Apache, it then sends the REMOTE_USER, > >> correctly. > >> > >> To realize the authentication in production, i am using one > >> middleware, and one backend as found in > >> django documentation. > >> > >> I would like to have only one setting in the project > >> thesite/settings.py, a boolean called EXTERNAL_AUTH, > >> controling the content of AUTHENTICATION_BACKENDS and > >> MIDDLEWARE_CLASSES. > >> > >> The code modifying those two variables will stand in my application > >> my/settings.py, It would then look like this > >> > >> from django.conf import settings > >> if settings.EXTERNAL_AUTH == False: > >> # Disabling standard login/logout. > >> settings.LOGIN_REDIRECT_URL='/' > >> settings.LOGIN_URL='/my/accounts/login/' > >> settings.LOGOUT_URL='/my/accounts/logout/' > >> else: > >> settings.AUTHENTICATION_BACKENDS = ( > >> ('my.backends.LDAPUserBackend', ) + > >> settings.AUTHENTICATION_BACKENDS) > >> > >> # Insert LDAPUserMiddleware right after AuthenticationMiddleware > >> index = settings.MIDDLEWARE_CLASSES.index( > >> "django.contrib.auth.middleware.AuthenticationMiddleware") > >> settings.MIDDLEWARE_CLASSES = > >> (settings.MIDDLEWARE_CLASSES[:index+1] + > >> ('my.backends.LDAPUserMiddleware', ) + > >> settings.MIDDLEWARE_CLASSES[index+1:]) > >> > >> EXTERNAL_AUTH is used at different locations in my application, for > >> example I use it to decide whether or not > >> I display the "change password" link. > >> > >> When I start testing, toggling EXTERNAL_AUTH, the behavior is fuzzy. > >> It inconsitently redirect me to the accounts/login > >> even if I'm authenticated through apache. I guess the middleware > >> isn't called but when I raise an error, the debug page > >> contradicts this. > >> > >> I'm a bit lost. Do you have any hint? > >> > >> Regards, > >> > >> > >> > >> > -- Drew Ferguson AFC Commercial http://www.afccommercial.co.uk -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.

