thulasi-ram / django-feature-toggle

Feature Toggle implementation as a pluggable django app. Supports SimpleToggle, TimeBombToggle ways to manage release of new features that can be easily toggled on / off.
GNU General Public License v3.0
8 stars 2 forks source link

Add FEATURE_TOGGLES settings dict (and management command) for initial setup #9

Open bittner opened 3 years ago

bittner commented 3 years ago

We deploy django-feature-toggles with our Django application in a cloud-native setup on Kubernetes. The toggles are all initialized at application startup using a management command. We don't manually create any of them.

Side note: In fact, we'd prefer to have the Admin user interface if "Feature Toggles" read-only, apart from the possibility to change a toggle value!

As the setup is really tied to the state of our source code, we have added a FEATURE_TOGGLES dict value to the Django settings of our application. We then initialize the toggle based on that:

FEATURE_TOGGLES = {
    'ANONYMOUS_LIKES': {  # name can contain max 20 uppercase characters A-Z
        'is_active_by_default': True,
    },
    'SHOW_ADVERTISING': {
        'is_active_by_default': False,
    },
    'HOMEPAGE_VIDEO': {
        'is_active_by_default': False,
    },
    'ADVERTISE_NEWSLETTER': {
        'is_active_by_default': True,
    },
}

Suggested Change

If that sounds like a valid use case I'd suggest you add a default management command that would initialize the toggles in the database based on such a FEATURE_TOGGLES dictionary in the Django settings. It could be made flexible, so that people that would want to configure environment too might optionally specify that in the dict, in addition.

thulasi-ram commented 3 years ago

Agreed this would be a nice addition. But how does this fare against creating a migration to bootstrap this?