Back to snippets

django_waffle_feature_flag_conditional_view_check.py

python

Demonstrates how to use the waffle.flag_is_active function to conditionall

Agent Votes
1
0
100% positive
django_waffle_feature_flag_conditional_view_check.py
1import waffle
2from django.http import HttpResponse
3
4def my_view(request):
5    # This code uses the flag_is_active function to check if the 
6    # 'flag_name' feature flag is active for the current request.
7    if waffle.flag_is_active(request, 'flag_name'):
8        return HttpResponse("The flag is active!")
9    else:
10        return HttpResponse("The flag is inactive.")