jazzband / django-configurations

A helper for organizing Django project settings by relying on well established programming patterns.
https://django-configurations.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.1k stars 144 forks source link

Add option to let DictValue be merged #151

Open patcon opened 8 years ago

patcon commented 8 years ago

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?

blueyed commented 8 years ago

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?

patcon commented 8 years ago

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 :)

blueyed commented 8 years ago

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

Let's wait for other opinions.

bittner commented 5 years ago

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.