Since the release of Django 2.0 I have been putting it off to do the upgrade from v1.11 This has so far worked in my favor because it means I can focus on other things that interest me like new projects or something new I am learning. But like all procrastination tasks it will eventually come for you.
Then Django 2.1 was released 1 August 2018 and when I saw this I thought this is a sign from the heavens above that I need to start looking into this. There has been other security releases since then, but nothing stood out more than that of 2.1. The project I will be upgrading is currently running v1.11 which is the LTS version, with extended support ending April 2020. So why the fuss?
The sooner I can move the project into the new version the less I will have to panic as time runs out.
Here is the release plan taken from the Django website:
The plan of action will include upgrading the django package then running some tests and that should be that. It is always key to verify the changes that were made in the version jump so in case you need to make changes to your code you do so. Here is a link of the change log.
- Check Django version
python -m django --version
2. Run tests
Let us run some tests to understand what potential problems our solution has when we run the upgrade. This will expose any code that has been deprecated.
python -Wa manage.py test --settings=PROJECT.settings.dev
Examine your results and if there are any issues in your code, fix it line by line.
3. Run upgrade
We can now upgrade the Django package, which is fairly simple. After this we should be ready to run our project with the new updated django version.
pip install -U Django
This should give you the following output:
Using cached https://files.pythonhosted.org/packages/d1/e5/2676be45ea49cfd09a663f289376b3888accd57ff06c953297bfdee1fb08/Django-2.1.3-py3-none-any.whl
Requirement already satisfied, skipping upgrade: pytz in ./prod_env/lib/python3.5/site-packages (from Django) (2017.3)
Installing collected packages: Django
Found existing installation: Django 1.11.1
Successfully uninstalled Django-1.11.1
Successfully installed Django-2.1.3
Now that we are all set we can continue as normal.
4. Run project
python manage.py runserver --settings=PROJECT.settings.dev
If all went well this is what you should see.
Django version 2.1.3, using settings 'PROJECT.settings.dev'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Hopefully this helps you in some way, and also proves that; no upgrade has to break your PC… Windows!!
I have some other posts on Django on my profile here, have a look and goodluck!