Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to override via query parameter and persist for session? #130

Open
truthdoug opened this issue Oct 11, 2024 · 0 comments
Open

Ability to override via query parameter and persist for session? #130

truthdoug opened this issue Oct 11, 2024 · 0 comments

Comments

@truthdoug
Copy link

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:

  1. query parameter - if it exists on the current request, that trumps all (and is set on the session)
  2. django session value - if the feature is explicitly set or unset in the session, use that
  3. 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant