Skip to main content

A set of simple feature flipper template tags that can be easily extended.

Installation

To install this, simply pip install django-feature-flipper.

Usage

Configure your INSTALLED_APPS in settings.py

INSTALLED_APPS = (
  ...
  'feature_flipper',
  ...
)

This gives you access to the basic feature flipping models and template tags. You can then use the basic FeatureFlipper that turns flags on and off depending on your user, or customise your own.

Basic Feature Flipper

Set the flag choices in your settings.py file as:

FEATURE_FLIPPER_FLAGS = (
  ('simple_feature', u'Simple Feature'),
  ('beta_testing', u'Beta Testing'),
)

When you add features, simply add flags here and your application will be able to access the new flags immediately.

Custom Feature Flipper

To customise the feature flipper you can just extend feature_flipper.models.AbstractFeatureFlipper with your own field. This provides a major advantage over the basic flipper by letting you determine your own reference for filtering out whether users get a feature or not.

First, extend the AbstractFeatureFlipper model:

from feature_flipper.models import AbstractFeatureFlipper


class MyFeatureFlipper(AbstractFeatureFlipper):
  """
  """
  USER_FEATURE_FIELD = 'company'

  company = models.ForeignKey('myapp.Company')

The USER_FEATURE_FIELD sets the field that should be used for lookups when determining whether to show the feature to a user. The final part is to reference this in your settings.py:

FEATURE_FLIPPER_MODEL = 'myapp.MyFeatureFlipper',

Using in Templates

To use the feature flipper in your templates, just load the feature_flipper library and use the flipper template tag:

{% load feature_flipper %}

<ul class="features">
  {% flipper request.user "simple_feature" %}
  <li><a href="/simple">Simple feature</a></li>
  {% endflipper %}

  {% flipper request.user "beta_testing" %}
  <li><a href="/testing">Beta-testing feature</a></li>
  {% endflipper %}
</ul>

The feature tag

The feature template tag is a simple template tag that takes two arguments:

  1. The user requesting access

  2. The feature string to check for

For custom feature flippers, the user argument is simply the alternative user identifier, for example the user’s organisation.

Supported Django Versions

This supports Django 1.9 and later.

Feature Flipper

Django

0.0.7

1.9

Metadata

Release files for django-feature-flipper 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-feature-flipper 0.1.1
File Size Uploaded
django-feature-flipper-0.1.1.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-feature-flipper 0.1.1
File Interpreter ABI Platform
django_feature_flipper-0.1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 14.9 kB

Release files / django-feature-flipper-0.1.1.tar.gz

Download URL django-feature-flipper-0.1.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
34824c5ae4576091c59d6a30cbc04959432de3f953ffe53654dcadfd21ced4d5
BLAKE2b-256 checksum
How to use checksums
f08a7bbc12043b8ee6d76a64efde528638da72ce63089e18e07111a20de254c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_feature_flipper-0.1.1-py2.py3-none-any.whl

Download URL django_feature_flipper-0.1.1-py2.py3-none-any.whl
Size 9.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
89058669bd39a2921b73359a42c01f88c573c5bf7296e53fc632faf873c68351
BLAKE2b-256 checksum
How to use checksums
59bcf3cfbab0f616380a35fd86d608659df7cbb8f1872e3bf70d29252dd7fec2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.1.3

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.8

3 release files

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page