Skip to content

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

Description

@truthdoug

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions