DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Getting to Continuous Deployment in Django: Feature Flipping with Gargoyle and Django Waffle

Getting to Continuous Deployment in Django: Feature Flipping with Gargoyle and Django Waffle

Nitya Oberoi user avatar by
Nitya Oberoi
·
Mar. 07, 12 · Interview
Like (0)
Save
Tweet
Share
5.33K Views

Join the DZone community and get the full member experience.

Join For Free

this post is a first in a series of posts about our move towards continuous deployment using django.


continuous deployment is a process by which code that is written for an application is constantly deployed into production without manual intervention. this allows us to be agile, to quickly innovate, and more importantly, to bounce back from any grave errors, unscathed.

when it comes to building new features, this can involve merging feature branches, rigorous code review, testing, and deployments, before you can test it out on a live environment. every subsequent release to different groups of users would require code changes, and deployment.

this can be avoided by employing feature flipping , which is an essential step towards achieving continuous deployment in your application.

so what is this feature flipping thing, anyway?

in its most basic form, you can think of it as applying an on/off switch to a piece of code in your codebase thereby releasing or rolling back a feature.

this allows you to constantly push new code for features that you’re not quite ready to release to any of your users yet. and when you’re ready, you can do a gradual rollout of the feature - to various groups of users. all, from a simple dashboard, with a single click.

analysis of django feature flipping libraries

there are a number of open source libraries in django that can be used for this purpose. recently, we analyzed our various options - the two biggest contenders were gargoyle and django waffle . following is the result of our evaluation:

ease of installation:

both libraries can be installed via pip or easy install and have to be included in your list of installed_apps. waffle also requires you to add a middleware and a context_processor for templates.


switches and flags:

both libraries support applying a switch to a piece of code via a conditional, a decorator to a view or template tags in django.

gargoyle, however, allows you to set conditions to your switches such as percentage of users, groups or specific users. it also allows us to associate percentages with users ip address - release it to 30% of ny, 10% of chicago etc.

waffle takes a different approach to this and uses flags, which when activated can be applied to groups, specific users, or a set percentage of users. although flags can be triggered in every way that a switch can be, they are tied to request objects while switches are named booleans in the database. the flipping uses cookies and is session based so ‘smart’ users can get around it but this can be avoided by adding a user to a group when they initially encounter the feature, and enabling the feature for that group.

usage in javascript:

waffle allows us to use switches and flags in javascript by including the appropriate js file and using the global waffle object.

if (waffle.flag('some_flag')) {
   // flag is active.
} else {
   // flag is inactive.
}`
`
if (waffle.switch('some_switch')) {
   // switch is active.
} else {
   // switch is inactive.
}


gargoyle does not currently support javascript.

admin frontend:

although not necessary, gargoyle encourages the use of nexus for the django admin frontend. if you choose not to do this however, you will need to enable the discovery of gargoyle.py modules in your urls.py.

import gargoyle
gargoyle.autodiscover()`

final thoughts

as mentioned earlier, both libraries are strong contenders in the django feature flipping community and can be easily forked on github to add extra functionality if required, instead of reinventing the wheel.

finally, while feature flipping definitely has its upsides it can have its disadvantages. although this means less merges, continuous integration and frequent and smaller deployments, constant maintenance of the codebase is necessary once a feature is completely released so you don’t have to maintain multiple versions.

nitya oberoi is a developer at yipit.


Continuous Integration/Deployment Django (web framework)

Published at DZone with permission of Nitya Oberoi. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Spring Boot, Quarkus, or Micronaut?
  • The Path From APIs to Containers
  • Fargate vs. Lambda: The Battle of the Future
  • The 5 Books You Absolutely Must Read as an Engineering Manager

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: