liveBook · Manning

Waffle Flag

As explained in Django in Action

A Django Waffle feature flag that controls feature availability according to configured visitor, group, percentage, cookie, testing, and override criteria.

A Waffle Flag is a Django Waffle control for releasing a new feature to selected visitors instead of every user at once. Put the new behavior behind a conditional check, configure who qualifies, and let beta users encounter it while everyone else keeps the familiar path. This limits the blast radius of a bad assumption without hiding the code in a separate branch forever. section 13.4 section 13.6

Django Waffle offers three levels of control. A Switch is globally on or off; a Sample enables a feature for a percentage of visitors; a Flag is the detailed option, deciding visibility from configured visitor attributes such as role, account, language, group, and other criteria. Use a Flag when “some users” needs a clearer definition than “a random slice.” section 13.4 section 13.6

Set up Django Waffle before relying on any of its controls:

  • Install the django-waffle package with pip. section 13.4
  • Add waffle to INSTALLED_APPS and waffle.middleware.WaffleMiddleware to MIDDLEWARE so requests can be evaluated against Waffle configuration. section 13.4
  • Run migrate, because Waffle stores its configured state in database tables. section 13.4

Beta access for a new RiffMates feature

Suppose a new musician-profile workflow is ready for feedback but not ready for every visitor. Guard that workflow with a Waffle Flag and configure the flag for the intended beta audience, such as a group or account category. Qualifying visitors see the new path; others continue using the existing one. Tests still matter: flags reduce release risk, but they cannot correct a misunderstood requirement. section 13.4 section 13.6

How Django in Action covers it

How deep it goes
Defines Flags through their targeting role and installation requirements, without detailing flag-evaluation code.
Examples
Uses a beta RiffMates musician-profile workflow targeted to a configured audience.
What it assumes
Assumes a Django project and teaches the required package, settings, middleware, and migration setup.
What you can do after
Operate/configure a Waffle Flag to expose a feature only to visitors meeting selected criteria.
How it connects
Connects Waffle Flags with feature flags, Waffle Switches, Samples, middleware, migrations, and Django Admin.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.