A feature flag wraps new application code in a conditional so functionality can be enabled for some users while remaining hidden from others. This lets users beta-test production code and limits the risk of bad design decisions or misunderstood requirements. section 13.4
Django Waffle provides three levels of control: switches turn a feature on or off globally, samples expose it to a percentage of visitors, and flags select visitors using finer-grained criteria. section 13.4 section 13.6
A practical Waffle setup follows this path:
- Install the package with `python -m pip install django-waffle`. section 13.4
- Add `waffle` to `INSTALLED_APPS` and `waffle.middleware.WaffleMiddleware` to `MIDDLEWARE`. section 13.4
- Run `migrate`, because Waffle stores its state in database tables. section 13.4
- Create controls through Django Admin or a management tool, then test them in application conditionals. section 13.4
A global rollout
Create a Waffle Switch named `new_profile`, then query it with `switch_is_active("new_profile")`. The returned Boolean decides whether the new profile code runs. For a percentage rollout, use a Sample and evaluate `sample_is_active()`; for user-specific targeting, use a Flag. section 13.4 section 13.6







