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', PIPELINE = { 'PIPELINE_ENABLED': True, 'JAVASCRIPT': { 'stats': { 'source_filenames': ( 'js/jquery.js', 'js/d3.js', 'js/collections/*.js', 'js/application.js', ), '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:
Issue:
from django.db.models.loading import get_models ImportError: No module named loading
Solution:
from django.apps import apps
Issue:
from django.utils.importlib import import_module ImportError: No module named importlib
Solution:
from importlib import import_module
Issue:
class ProductAdmin(reversion.VersionAdmin): AttributeError: 'module' object has no attribute 'VersionAdmin'
Solution:
from reversion.admin import VersionAdmin
Issue:
@reversion.register NameError: name 'reversion' is not defined
Solution:
from reversion import revisions
Issue:
django.utils.log.NullHandler class not found
Solution:
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.