from flags.state import ( flag_state, flag_enabled, flag_disabled, )
If any of the flag state checking functions below is used at the top-level of a module (in
urls.py, for example), it will be evaluated at import-time. This may have unintended consequences. Database flag conditions may not be available, custom conditions may not be registered, and any dynamic change in flag state (such as date-based conditions or a newly added database condition) will not have an effect.
Consider using the flagged URLs API for state-checking in
urls.py, the view decorators and the class-based view mixin for state-checking Django views, and using the state checking functions below inside methods and functions. This will have the added benefit of ensuring that the intention is clear, and that flagged code is as tightly-scoped as possible.
Return the value for the flag (
False) by passing kwargs to its conditions. If the flag does not exist, this will return
None so that existence can be introspected but will still evaluate to
True if a flag is enabled by passing kwargs to its conditions, otherwise returns
if flag_enabled('MY_FLAG', request=a_request): print("My feature flag is enabled")
True if a flag is disabled by passing kwargs to its conditions, otherwise returns
if flag_disabled('MY_FLAG', request=a_request): print(“My feature flag is disabled”)