Anyone who knows me will know that Django is my favourite web framework. On the second of September 2014, Django 1.7 was finally released to the public after a much anticipated wait. Some of the new features coming out in 1.7 include App Loading refactoring, custom Queryset methods and a bunch of minor updates to make Django development smoother than it has ever been before.

However, the most exciting feature present in the new version is database schema migration management. This feature update was driven primarily by Andrew Godwin, after a successful Kickstarter campaign to work on the integration. Andrew is the author of the original schema migration package South and the entire community is forever grateful for the contributions he has given to the platform.

When I first used Twilio, I stumbled upon Randall Degges’ helper library for Django, django-twilio. I offered my technical support to Randall after emailing him about the fantastic library he created. After some great Python banter he let me have access to the repository to help continue the work he started.

With the advent of Django 1.7, Django Reusable Apps (the term used to refer to plugins) will need to be updated to support both Django 1.7 migrations and pre-Django 1.7 database migrations.

I recently had to update the django-twilio reusable app to do just this and I decided to document the procedure in order to provide other maintainers with a quick how-to on easily updating their own projects.

This guide only covers database migrations management support for Django 1.7, no other new 1.7 features.

What We’ll Cover

This guide assumes you are familiar with Python, virtualenv, PyPI and Django open source project development. Even so, to keep up with The Zen of Python, I’m going to be explicit about the steps required to reliably update your Django reusable app.

In this guide I’ll cover:

Setting up two separate virtual environments for Django 1.7 and Django 1.6 respectively.

Updating the migrations files to support Django 1.7 and Django 1.6

Running the migrations for your Django reusable app in both versions

Updating the documentation to cover both versions of Django

Configuring Virtual Environments

The quickest, most reliable way to test compatibility with both Django 1.7 and Django 1.6 is to install both versions on separate virtual environments. If you are unfamiliar with virtualenv, it is a tool that allows you to “sandbox” Python development environments so you do not encounter dependency issues from multiple projects with multiple versions.

The new virtual environments will be directories within the root of your project. You will need to cd into the root of your project directory.

I am going to be using the word “django-package” to refer to the Django reusable app we are updating, be sure to substitute it with the name of your own reusable app. I’ve also taken screenshots of the procedure with django-twilio, to give you visual support.

With virtualenv installed we can create new virtual environments with the following commands: