Feature Flags#
Waffle is the top library for managing feature flags in Django. Pegasus includes configuration for using Waffle with or without teams.
If you are using Teams then the Waffle flags can be turned on based on the user or the team. If you are not using Teams then flags only apply to users.
Usage#
Waffle can be used to turn on and off features. For example:
import waffle
def my_view(request):
if waffle.flag_is_active(request, 'flag_name'):
"""Behavior if flag is active."""
else:
"""Behavior if flag is inactive."""
The flags themselves are managed via the Django Admin site where each flag can be activated for specific users or teams, or based on certain conditions such as superuser status. Flags can also be managed via the command line.
For full details on configuring flags see the Flag Attributes of the Waffle docs.
Flags may be used in views, templates, JavaScript and more. For full details see the Waffle docs
Usage with Teams#
If you are using Teams, Pegasus ships with a custom flag model which allows you to activate flags on a per-team basis in addition to the other default options.
Example usage#
To see flags in actions look at the “Flags” example in the Pegasus Example Gallery.
The flag in the example is configured in test mode which allows us to activate the flag with a URL parameter.