edx-toggles

raw JSON →
6.0.0 verified Mon Apr 27 auth: no python

Library and utilities for feature toggles in Open edX, built on top of Django Waffle. Current version 6.0.0. Release cadence: irregular, roughly quarterly.

pip install edx-toggles
error ModuleNotFoundError: No module named 'edx_toggles'
cause The package is not installed.
fix
Run pip install edx-toggles.
error ImportError: cannot import name 'LegacyWaffleFlag' from 'edx_toggles.toggles'
cause LegacyWaffleFlag was removed in version 5.0.0.
fix
Use WaffleFlag instead. See migration guide.
breaking In version 5.0.0, the LegacyWaffleFlag, LegacyWaffleSwitch, and LegacyWaffleFlagCourseStaff classes were removed. Code using them must be migrated.
fix Replace LegacyWaffleFlag with WaffleFlag and LegacyWaffleSwitch with WaffleSwitch.
deprecated The module `edx_toggles.waffle_utils` is deprecated. Use `edx_toggles.toggles` instead.
fix Update imports to use the new toggles module.
gotcha WaffleFlag requires a `module_name` argument to properly generate the cache key. Omitting it can cause incorrect toggle behavior.
fix Always pass `module_name=__name__` when creating WaffleFlag.

Create and check a WaffleFlag.

from edx_toggles.toggles import WaffleFlag

flag = WaffleFlag('myapp.my_flag', __name__, module_name=__name__)
if flag.is_enabled():
    print('Feature is enabled')
else:
    print('Feature is disabled')