django-configurations icon indicating copy to clipboard operation
django-configurations copied to clipboard

Add option to let DictValue be merged

Open patcon opened this issue 9 years ago • 4 comments
trafficstars

Would be awesome if the default could be set, and the envvar value is merged into this default :)

https://django-configurations.readthedocs.org/en/stable/values/#configurations.values.DictValue

So if this was done:

default = {
  'foo': 'val1',
  'bar': 'val2',
}
MY_SETTING = values.DictValue(default)
export DJANGO_MY_SETTING="{'foo':'my new cal'}"

Then the value of settings.MY_SETTING would have keys for both foo and bar.

Thoughts?

patcon avatar Mar 13 '16 01:03 patcon

This can be achieved currently using the setup methods: https://django-configurations.readthedocs.org/en/stable/patterns/#setup-methods

What about merging it there from a var/setting with another name, e.g. DJANGO_MY_SETTING_ADD?

blueyed avatar Mar 21 '16 22:03 blueyed

Ah cool! Using the setup methods elsewhere, but hadn't considered for this. You sure this isn't a helpful enough pattern to make it a flag? It would seem rather intuitive behaviour if provided :)

patcon avatar Mar 22 '16 15:03 patcon

I'm not too convinced, but would not vote against it.

Let's wait for other opinions.

blueyed avatar Mar 22 '16 21:03 blueyed

In my opinion, using setup methods is clunky. How do we sell django-configurations' advantages if the result of code like this is cumbersome (and less readable). I have a similar issue in #217.

bittner avatar Dec 10 '18 00:12 bittner