Skip to content

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

@bittner

Description

@bittner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions