django-flags
django-flags copied to clipboard
Ability to override via query parameter and persist for session?
A pattern we've used (with internal code, not django-flags):
- have a site-wide feature flag, either in django settings or (more commonly) in django-constance
- middleware or hook that detects query parameters that explicitly choose one state or the other. For example, if the feature is called
newfeature
then?newfeature
would always enable it and?no-newfeature
would disable it - the middleware also stores the overriden value in the django user session
With this the priority of choosing the feature or not is:
- query parameter - if it exists on the current request, that trumps all (and is set on the session)
- django session value - if the feature is explicitly set or unset in the session, use that
- global value - otherwise use the site-wide setting
I'm newly finding out about django-flags and I've read through examples in the documentation but don't readily see a way to implement this overriding behavior. Is there a way to do this? Perhaps with a combination of conditions for the feature?