[Answer]-Load specific settings when user try to acces to an app (multi app django)


What you’re trying to do sounds a little… off. I agree with Daniel Roseman. If you’re looking for advise, listen to him. But if you’re bent on trying to make this work, here’s an idea: you MIGHT be able to do this from a view with a mixin that calls settings.configure():

from os
from django.conf import settings
import configparser

class DynamicSettingsViewMixin(object):

    def dispatch(self, request, *args, **kwargs):
        config = configparser.ConfigParser()
        config.read(os.path.join(os.path.dirname(__file__), 'settings.ini'))


        return super(DynamicSettingsViewMixin, self).dispatch(request, *args, **kwargs)

class MyAwesomeAppView(DynamicSettingsViewMixin, TemplateView):

I haven’t tried this… since it’s crazy.


Apps don’t, and can’t, have separate settings. If you need to do this (which I must say sounds like a bad idea), you will need separate projects, each with their own settings.py, and each served by their own virtual server in Apache.

Leave a comment