0

I am attempting to set up multiple configurations. The idea is to have a central back-end and in the site_settings.py to change one line to switch between te configurations, instead of pasting the different configs in the site_settings.

#config1.py

from __future__ import absolute_import
from __future__ import unicode_literals

from .defaults import *  # noqa


SOMECONFIG = NEWS_CONFIG = 'something'

MAPPED_ITEMS = {
    'Something': {
        'from': {
            'provider': 'someprovider',
            'app': 'test',
            'model': 'Test'
        },
        'to': {
            'provider': 'someprovider',
            'app': 'test',
            'model': 'Test'
        }
    },
    'Something2': {
        'from': {
            'provider': 'someprovider',
            'app': 'test',
            'model': 'Test'
        },
        'to': {
            'provider': 'someprovider',
            'app': 'test',
            'model': 'Test'
        }
    }
}

And basically the other configuration file is the same, just with a different SOMECONFIG = NEWS_CONFIG = 'something2' and ofcourse the MAPPED_ITEMS are different

The problem is, in the app's that I am using, it takes the config from the settings and not from these config files. I would like to have a line in the site_settings.py to determine what config file it should use

dnsko
  • 1,017
  • 4
  • 17
  • 29
  • See this answer: http://stackoverflow.com/a/15325966/1081569 – Paulo Almeida Apr 05 '16 at 14:54
  • It hasn't particularly to do with local or production settings, I'd just like to switch settings quickly while working on multiple companies. The project is a central backend and each company has its own mapped_items. The idea is to quickly set something along the lines of this `SETTINGS = company1.py` – dnsko Apr 05 '16 at 15:00
  • 1
    Yes, but it's the same idea. Use the `--settings` switch to select the correct settings. – Paulo Almeida Apr 05 '16 at 16:13

1 Answers1

0

Your site_settings file can be named as base.py, which is the common settings file. Then inherit the base.py into your config.py(dev.py or production.py) file

config1.py (dev.py)

from base import *
SOMECONFIG = NEWS_CONFIG = 'something'

config2.py(production.py)

from base import *
SOMECONFIG = NEWS_CONFIG = 'Anything'

Use this config file as your actual settings file

Mani
  • 933
  • 6
  • 15