Reputation: 315
I have added feature flags in my django using package django-waffle. I defined a switch in django admin panel. The default Switch model provides all the necessary functionality.To list all the switches using manage.py, we use this command:
./manage.py waffle_switch -l
How to list all the switches in views.py?
Upvotes: 1
Views: 229
Reputation: 159
Something like that should work for switches
from django.http import HttpResponse
from waffle import get_waffle_switch_model
def index(request):
switches = get_waffle_switch_model().get_all()
switch_values = [(f.name, f.is_active(request)) for f in switches]
return HttpResponse(switch_values)
and for feature flags
pretty similar:
from django.http import HttpResponse
from waffle import get_waffle_flag_model
def index(request):
flags = get_waffle_flag_model().get_all()
flag_values = [(f.name, f.is_active(request)) for f in flags]
return HttpResponse(flag_values)
Upvotes: 0