Question

Are there any caveats with using Waffle Switches to conditionally change settings in my project's settings.py?
For instance, is it required to restart the Django process for the changes to take effect?
And if a restart is required, what is the best way to do this automatically?

Was it helpful?

Solution

I created Waffle. It doesn't replace settings, or interact with them in the same way constance is designed to.

There are things that could be either a setting, or a waffle switch, but those are two different ways to approach it.

from django.conf import settings
def my_function():
    if settings.SOME_SETTING:
        # do one thing

vs

from waffle import switch_is_active
def my_function():
    if switch_is_active('my-switch'):
        # do something

The big difference is that if you change a setting, you'll have to restart your Django process (unless the setting is used in a cron job or management command or something else that's not a web request). If you change a waffle switch, you don't need to restart anything.

And, just for completeness, to the last part of your question: waffle flags require a request, because they have many criteria for being active, but samples and switches don't. Their value doesn't depend on a request.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top