nitely / django-djconfig

:gear: Dynamic configuration made easy
http://django-djconfig.readthedocs.org
MIT License
32 stars 5 forks source link

Setting a key within data migrations #19

Closed nitely closed 8 years ago

nitely commented 8 years ago

Currently when a key is setted via the config form within a migration, the override_djconfig will not work in some cases (ie: self.client.get(...)). This is because if the middleware is called, it will reload the config since there is something in the confg table, thus overriding all settings. To avoid this, override_djconfig should call reload_maybe and then override the desire settings.

Also, if someone is doing this, it's likely s/he will want to call reload_maybe wihin the setUp method or the migration itself, so it should be described in the docs as a tip.

form.save already calls reload_maybe so no need for calling it manually. Since the tests has to run the migrations before the test is called, override_djconfig will work properly.

The migration should deppend on the djconfig initial migration.