Steps to Upgrade Django 1.6 to 1.9

Steps to Upgrade Django 1.6 to 1.9

This document will help in migrating the Existing application that was developed using Django from 1.6 to 1.9. Here is a series of steps that need to be followed to get the latest Django up and running.

Note: Before starting the process I strongly suggest you take a backup of the Existing application database.

Update required versions in existing settings file:

In the application directory, there will be a Settings File for the respective environment like local.txt, test.txt ...etc. Pick up one of the settings files and the environment you want to upgrade the Django version. Select the latest and Stable version of Django, change the version numbers in the settings file. For every version of Django, there will be:

A release note provided (Read the release not and understand it clearly)

Look for all other dependencies and make the versions accordingly in the settings file

Install latest Django Library:

Once you made the changes in the settings file and set everything ready for migration, start with the below command.

pip install -r requirements/base.txt

So, pip removes older version of Django from the current environment and it will reinstall the latest one in the Settings.

Uninstall the model manager:

In Django 1.6 South has been the model manager but in 1.7 it was deprecated. So, from the Django application all the dependencies of south must be removed. Follow the steps below to uninstall the model manager.

·        pip uninstall south

·        Remove 'south' module entry from INSTALLED_APPS of Django application settings

·        Delete all your (numbered) migration files from "migrations" directory. If the project contains multiple application all migration files

·        Different apps must be removed, but not the directory or __init__.py - make sure you remove the. pyc files too

Make the migrations to your application:

As Django applications require database connectivity, take care of the migrations. There is not much change in migration but yes commands that are used to achieve are a bit different.

python manage.py makemigrations

python manage.py migrate --fake-initial (this option is preferably used to do a migration on the existing database for an existing application)

Necessary code changes:

Now it’s time for resolving issues in existing code base. As per the current scenario migrating from 1.6 to 1.9, there were a lot many releases to look after. Be careful when it comes to code changes that are made in different releases. Have a quick run-through the releases to get basic knowledge about the changes.

There could be some issues with the code like urlsconf, admin sites, library functions and the templating styles - address these problems, once done with these issues. Collect all static files related to current Django application. This phase could be rare, but in case you fall in static files issue just run the command below:

python manage.py collectstatic

Start Django server by this command:

python manage.py runserver

application will start and a new version of Django will be up and set running.

Do let me know your thoughts writing to me at [email protected] or use the comments section below.

For more details on managed services support or software upgradation support, visit https://www.suneratech.com/

要查看或添加评论,请登录

社区洞察

其他会员也浏览了