Defining flags


Default: ('flags.sources.SettingsFlagsSource', 'flags.sources.DatabaseFlagsSource',)

A list or tuple containing the full Python path strings to classes that provides a get_flags() method. The get_flags() method is expected to return a dictionary of flags and Condition objects. All flags returned by all flag sources will be available to check.


Default: {}

A dictionary of feature flags and optional conditions used when 'flags.sources.SettingsFlagsSource' is in FLAG_SOURCES.

Conditions can either be included as:

  • A list of dictionaries with the format:
    {'condition': 'condition name', 'value': 'expected value', 'required': True}`
    {'condition': 'condition name', 'value': 'expected value'}
    (required defaults to False).
  • A list of 3-tuples with the format:
    (condition name, expected value, required)
  • A list of 2-tuples with the format:
    (condition name, expected value)
    (required defaults to False)

For example:

    {'condition': 'condition name', 'value': 'expected value to be enabled'},
    {'condition': 'condition name', 'value': 'expected value to be enabled', 'required': True},
    ('condition name', 'expected value to be enabled'),
    ('condition name', 'expected value to be enabled', True),
  # This is possible, but not recommended
    {'condition': 'condition name', 'value': 'expected value to be enabled'},
    ('condition name', 'expected value to be enabled', True),

Previously flag definitions in FLAGS supported a single dictionary (rather than a list) with the condition name as the key and expected value as value. This method of specifying flags is deprecated and will be removed in Django-Flags 5.0.


Default: False

If this setting is True Django-Flags will log all flag state checks with how the conditions were evaluated. These will appear in the log file like:

INFO:flags.sources:Flag MY_FLAG evaluated False with conditions: boolean (False).
INFO:flags.sources:Flag MY_FLAG evaluated True with conditions: boolean (False), path matches (True).

This is intended for use in tracking the history and usage of enabled featured flags.