Updating the software application to latest releases is very important. Because latest releases always includes new features which boosts development process and resolves potential problems.
Why to update to from Django 1.x to 2.x ?
- Django 1.0 is first stable version so, it obvious that it contains less features.
- Django 1.1 ORM improvements
- Aggregate support
- It includes RDBMS agregate features
COUNT(), MAX(), MIN()
, etc
- It includes RDBMS agregate features
- Query expressions(i.e F object)
F
object is a new feature in ORM queries. By usingF
queries we can refer to another field on the query and can traverse relationships to refer to fields on related models.
- Model Improvements
- Added
managed
option in django modelMeta
class. ifmanaged=True
then ORM can make database changes like dropping, creating and updating the table structure/data. - Default value of
managed
isTrue
- Added
- Aggregate support
- Django 1.2 new features
- Support for multiple database connections in a single Django instance.
- Model validation before saving the data into the database(i.e data type, uniqueness of database table record, etc)
- Improved protection against CSRF attacks.
- Django 1.3 new features
- Built-in support for writing class-based views using generic views.
- Built-in support for python logging.
- In previous versions of django it was common to place static assets in
MEDIA_ROOT
along with user-uploaded files, and serve them both atMEDIA_URL
. - Static assets should now go in
static/
subdirectories of our apps or in other static assets directories listed inSTATICFILES_DIRS
, and will be served atSTATIC_URL
.
- Django 1.4 features & deprecations
- Django 1.4 has dropped support for Python 2.4. Python 2.5 is the minimum required Python version.
- The Biggest feature added in this version is support for timezones. Based on the timezones datetime/date objects will be handled.
- It supports integration with in-browser testing frameworks like Selenium.
django.test.LiveServerTestCase
base class allows us to test the interactions with front-end and back-end.- ORM improvements includes
bulk_create
andprefetch_related
(i.e batch-load related objects).
- Django 1.5 features
- This release blasted with new feature Configurable User model where we can use our own user model.
- It’s also the first release that supports Python3.
- GeoDjango now supports PostGIS 2.0.
- It provides better support for streaming responses with class
django.http.StreamingHttpResponse
.
- Django 1.6 features
- It supports persistent database connections. This avoids the overhead of re-establishing a connection at the beginning of each request.
- Database transaction management improved. Database-level autocommit is now turned on by default. This makes transaction handling more explicit and should improve performance.
- It introduced a new test runner suit that allows more flexibility in the location of tests(i.e
django.test.runner.DiscoverRunner
). With test discovery, tests can be located in any module whose name matches the patterntest*.py
. - A new
django.db.models.BinaryField
model field allows storage of raw binary data in the database.
- Django 1.7 features & deprecations
syncdb
management command replaced withmigrate
django.db.models.signals.pre_syncdb
anddjango.db.models.signals.post_syncdb
have been deprecated and replaced bypre_migrate
andpost_migrate
respectively.django.utils.simplejson
is removed and we can use python’s json module(i.eimport json
).HttpResponse
,SimpleTemplateResponse
,TemplateResponse
,render_to_response()
,index()
, andsitemap()
no longer take amimetype
argument. It’s been renamed tocontent_type
.
- Django 1.8 features
- It now supports multiple template engines like
Jinja2
,django
,Mako
, etc. django-secure
third-party library had been integrated intoDjango
to improve the security.PostgreSQL
specific functionality likeArrayField
,HStoreField
,IntegerRangeField
,BigIntegerRangeField
, etc. fields support added.- Added ORM support for
Query Expressions
,Conditional Expressions
, andDatabase Functions
. - Improved the unittest functionality.
- It now supports multiple template engines like
- Django 1.9 features & deprecations
AUTH_PASSWORD_VALIDATORS
setting added to help prevent the usage of weak passwords by users.- Permission mixins support added for generic class based views.
- Implicit QuerySet
__in
lookup removed (i.eModel.objects.filter(related_id__in=RelatedModel.objects.all())
) - Dropped support for PostgreSQL 9.0, Oracle 11.1
- Django 1.10 features
- Enabled full text search for PostgreSQL database table columns
- The User model in
django.contrib.auth
originally only accepted ASCII letters and numbers in usernames.
- Django 1.11 features & deprecations
- The Django 1.11.x series is the last to support Python 2. The next major release, Django 2.0, will only support Python 3.4+
- Database table indexes available in model meta class (i.e
Meta.indexes
). - Template-based widget rendering support added.
- Added support for Subquery expressions
posts = Post.objects.filter(published_at__gte=one_day_ago) Comment.objects.filter(post__in=Subquery(posts.values('pk')))
- Dropped support for PostgreSQL 9.2 and PostGIS 2.0
- Django 2.0 features & deprecations
- It only support’s Python3.4+. It dropped support for Python<3.
- It simplified the url routing syntax by introducing the path converters.
- Responsive user interface feature for django admin.
Check list to update projects from Django1.x to Django2.x?
- Check-out the version of the django on which the project is running.
- It’s recommended to update the current version to it’s next version (i.e django 1.x to django 1.x+1).
- Before updating the django version first we have to read it’s release notes for what are the features deprecated and what are the features introduced.
- Find replacements for deprecated features.
- In most django projects we use many third party packages. So, we have to take care of them too.
- If any third party package is deprecated then first we have to check for alternatives to it. If any alternative is available then use it.
- If no alternative found then update the existing package and use it.
- Remove all unused third party packages.
- After satisfying the requirements(i.e system softwares and pip packages) run the tests.
- If any failures while running tests then fix them.
- Try to remove all unused code(i.e you can use test coverage)
- Try to optimize the existing code by replacing it with new features wherever it’s required to speedup the application.
- Try to optimize the existing ORM queries with new features of ORM to speedup the query execution.
- Try to use
path
andpath converters
to make urls more readable.
Thank you for reading the Agiliq blog. This article was written by Anjaneyulu Batta on Feb 4, 2019 in django , version update , software update .
You can subscribe ⚛ to our blog.
We love building amazing apps for web and mobile for our clients. If you are looking for development help, contact us today ✉.
Would you like to download 10+ free Django and Python books? Get them here