Django Update 1.6 to 1.9 – 1.8 to 1.9

Upgrading DJango from 1.8 to 1.9 was relatively easier as the main pain of upgrading DRF was all dealt with when I was upgrading Django from 1.6 to 1.8, which has been discussed here. A lot of libraries has to be updated which I came to know as and when I tried running the application.

One of the main issues that I had while the whole upgrade was creating the migration from scratch. The project had South for managing the migration, but since Django has now its inbuilt support, I removed this South and all the existing migration files. There were some circular dependency issues when creating the new migration. You may get an error as below.

django.db.migrations.graph.CircularDependencyError: partner.0001_initial, address.0001_initial, users.0001_initial

The reason was with some of the foreign keys. Django internally creates a graph data structure to figure out this dependency. You can get rid of it by removing the foreign keys temporarily, running the migrations and then creating the keys again.

These following libraries had to go for an update, mentioned with the version that I am using with the Django version 1.9:

Django Reversion 1.10.0, Django tables 2 1.0.5, Django Mptt 0.8.0,  Django Celery 3.2.1, Django Extensions 1.7.3, Django Haystack 2.5.1, Django Redis Cache 1.7.1, Django Redis Session 0.5.6

There are setting changes around the library – Pipeline. You can find the changes to be done on the library’s documentation page. The new settings are as such:

"STATICFILES_FINDERS - 'pipeline.finders.PipelineFinder', 
        'stats': {
            'source_filenames': (
            'output_filename': 'js/stats.js',

Other than this, there were some code changes which were introduced in Django 1.9, for which I had to change some import statements. Some frequent Django and other libraries’ issues:


from django.db.models.loading import get_models
ImportError: No module named loading


from django.apps import apps


from django.utils.importlib import import_module
ImportError: No module named importlib


from importlib import import_module


class ProductAdmin(reversion.VersionAdmin):
AttributeError: 'module' object has no attribute 'VersionAdmin'


from reversion.admin import VersionAdmin


NameError: name 'reversion' is not defined


from reversion import revisions


django.utils.log.NullHandler class not found


Use logging.NullHandler

This is pretty much it. Django upgrade is more of a task which needs a lot of patience than other things. Happy upgrading.

One thought on “Django Update 1.6 to 1.9 – 1.8 to 1.9

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s