Download - What's New in Django 1.6
![Page 1: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/1.jpg)
What’s New in Django 1.6
Sivasubramaniam Arunachalam
Nov 14, 2013
@sivaa_in
http://www.meetup.com/Bangalore-Django-User-Group/events/149839872/
![Page 2: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/2.jpg)
Malcolm
Tredinnick
(We miss you)
![Page 3: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/3.jpg)
Version Released Date Released After
0.9 Nov 16, 2005
0.91 Jan 11, 2006 2 Months
0.95 Jul 29, 2006 6 Months
0.96 Mar 23, 2007 8 Months
1.0 Sep 03, 2008 17 Months
1.1 Jul 29, 2009 11 Months
1.2 May 17, 2010 9 Months
1.3 Mar 23, 2011 10 Months
1.4 Mar 23, 2012 12 Months
1.5 Feb 26, 2013 11 Months
1.6 Nov 06, 2013 8 Months
![Page 4: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/4.jpg)
Django Version Supported Python
Version (2.x) Supported Python
Version (3.x)
1.0 2.3+
1.1 2.3+
1.2 2.4+
1.3 2.4+
1.4 2.5+
1.5 2.6+ 3.2+*
1.6 2.6+ 3.2+
1.7 2.7+ 3.2+
* Experimental
![Page 5: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/5.jpg)
Python 3 Officially Supported
(Enjoy it in Production)
![Page 6: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/6.jpg)
![Page 7: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/7.jpg)
![Page 8: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/8.jpg)
LTS Releases
https://docs.djangoproject.com/en/dev/internals/release-process/#long-term-support-lts-releases
Django 1.4 till March 2015
![Page 9: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/9.jpg)
New Features
• Simple Layout
• Improved Transactions
• Persistent DB Connections
• Others
![Page 10: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/10.jpg)
New Features
• Simple Layout
• Improved Transactions
• Persistent DB Connections
• Others
![Page 11: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/11.jpg)
Much Simpler (Project & App Layouts)
![Page 12: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/12.jpg)
Application - added admin
- removed sites
Middleware - added clickjacking prevention
Database - SQLite3
New Defaults
![Page 13: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/13.jpg)
Custom Templates (For Projects & Applications)
https://docs.djangoproject.com/en/1.6/ref/django-admin/#custom-app-and-project-templates
![Page 14: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/14.jpg)
startproject
• manage.py
• settings.py
• wsgi.py
• urls.py
![Page 15: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/15.jpg)
startproject
• manage.py
• settings.py
• wsgi.py
• urls.py
![Page 16: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/16.jpg)
Removed Settings
• ADMINS
• MANAGERS
startproject - settings.py
• STATIC_ROOT
• STATICFILES_DIRS
• STATICFILES_FINDERS
• TEMPLATE_DIRS
• TEMPLATE_LOADERS
• MEDIA_ROOT
• MEDIA_URL
• SITE_ID
• LOGGING
![Page 17: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/17.jpg)
Modified Settings
startproject - settings.py
![Page 18: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/18.jpg)
DATABASES (default to SQLite3)
startproject - settings.py - Modified
![Page 19: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/19.jpg)
TIME_ZONE (default to UTC)
startproject - settings.py - Modified
![Page 20: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/20.jpg)
INSTALLED_APPS (admin enabled & sites removed by default)
startproject - settings.py - Modified
![Page 21: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/21.jpg)
MIDDLEWARE_CLASSES (clickjacking protection is enabled by default)
startproject - settings.py - Modified
![Page 22: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/22.jpg)
New Settings
BASE_DIR
startproject - settings.py
![Page 23: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/23.jpg)
startproject
• manage.py
• settings.py
• wsgi.py
• urls.py
![Page 24: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/24.jpg)
admin enabled by default
startproject - urls.py
![Page 25: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/25.jpg)
startapp
• admin.py
• models.py
• views.py
• tests.py
![Page 26: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/26.jpg)
startapp
• admin.py
• models.py
• views.py
• tests.py
![Page 27: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/27.jpg)
admin.py is generated by default
startapp - admin.py
![Page 28: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/28.jpg)
startapp
• admin.py
• models.py
• views.py
• tests.py
![Page 29: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/29.jpg)
Default Example TestCase is removed
startapp - tests.py
![Page 30: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/30.jpg)
File
Django 1.5
Django 1.6
Change
Tar ball 8 M 6.6 M -17.5 %
settings.py 5.3 K 2.0 K -63.1 %
urls.py 556 297 -46.5 %
wsgi.py 1.4 K 387 -72.2 %
tests.py 383 60 -84.3 %
![Page 31: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/31.jpg)
New Features
• Simple Layout
• Improved Transactions
• Persistent DB Connections
• Others
![Page 32: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/32.jpg)
Improved Transactions (Biggest Change from 0.9x)
![Page 33: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/33.jpg)
Old APIs were Deprecated
Transactions
![Page 34: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/34.jpg)
New APIs were Introduced
Transactions
![Page 35: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/35.jpg)
Transactions – New APIs
• Clean & Simple
• Improved Performance
• Improved Error Handling
• Fine grained rollbacks between savepoints
Improvements
![Page 36: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/36.jpg)
Transactions – New APIs
• Enabled by default • Every single SQL Statement is committed immediately
• django.db.transaction.set_autocommit()
DB Level Auto Commit
![Page 37: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/37.jpg)
Transactions – New APIs
atomic() • New Single API to control DB transactions
• Commit on Success
• Rollback on Exceptions
• It can be
• Nested
• Used as a Decorator & Context Manager
![Page 38: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/38.jpg)
Transactions – New APIs – atomic()
Decorator
![Page 39: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/39.jpg)
Transactions – New APIs – atomic()
Context Manager
![Page 40: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/40.jpg)
Transactions
Backward Incompatible
https://docs.djangoproject.com/en/1.6/topics/db/transactions/
#transactions-upgrading-from-1-5
![Page 41: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/41.jpg)
Transactions
Excellent Presentations by
Aymeric Augustin
https://myks.org/en/talks/
More Details
![Page 42: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/42.jpg)
New Features
• Simple Layout
• Improved Transactions
• Persistent DB Connections
• Others
![Page 43: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/43.jpg)
New Connection for every HTTP Request
Till Django 1.5
Persistent DB Connections
![Page 44: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/44.jpg)
Same Connection will be reused between requests
In Django 1.6
Persistent DB Connections
![Page 45: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/45.jpg)
• Life Time of a Database Connection
• Different for each Database
• Default = 0 (Off & No reuse)
• For Unlimited, use None
• Comply with DB Idle Connection Settings
CONN_MAX_AGE
Persistent DB Connections
![Page 46: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/46.jpg)
• Connection is established during the first query
• Connection won’t be closed and reused for subsequent requests
• One Connection for each Worker Thread
• Once it is exceeds the CONN_MAX_AGE, it will be closed • Beginning & end of each request
Processing Behavior
Persistent DB Connections
![Page 47: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/47.jpg)
New Features
• Simple Layout
• Improved Transactions
• Persistent DB Connections
• Others
![Page 48: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/48.jpg)
Locates tests anywhere (test*.py)
New Test Runner
![Page 49: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/49.jpg)
QuerySet.dates() is now Time Zone Aware
(Earlier Only in UTC)
![Page 50: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/50.jpg)
QuerySet.dates() is now operates only on DateField() and returns datetime.date
![Page 51: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/51.jpg)
"hour", "minute" or "second“ lookups are supported
QuerySet.datetimes() is operates on DateTimeField()
and returns datetime.datetime
![Page 52: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/52.jpg)
BinaryField() is introduced
• Stores raw binary data in bytes
• Queryset is not possible
• Don’t use it to store static files
![Page 53: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/53.jpg)
django-admin.py check • Verifies the setup for Current Version
• Settings
• Application Code
• Warnings will be issued for incompatibles
![Page 54: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/54.jpg)
Efficient Model.save()
Before
SELECT is used to determine INSERT (or) UPDATE
Now
if instance has Primary Key, it is UPDATE
else, it is INSERT
![Page 55: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/55.jpg)
Model.objects.earliest()
(latest() with reverse direction)
![Page 56: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/56.jpg)
Model.objects.first()
• Returns the first object from QuerySet
• If no order specified, Ordered by PK
• None for EmptyQuerySet
![Page 57: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/57.jpg)
Model.objects.first()
![Page 58: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/58.jpg)
Model.objects.last()
![Page 59: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/59.jpg)
Model.objects.filter(timestamp__hour = 23)
Model.objects.filter(timestamp__minute = 59)
Model.objects.filter(timestamp__second = 59)
![Page 60: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/60.jpg)
ModelAdmin.preserve_filters
![Page 61: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/61.jpg)
HTML 5 Types for input fields
(Email, URL and Number)
Supported in • IntegerField
• FloatField
• DecimalField
• EmailField
• URLField
![Page 62: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/62.jpg)
Blank Password is Supported
![Page 63: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/63.jpg)
• SQLite Save Points is supported
• Open Layer based GeoDjango Forms API
• Pillow is preferred over PIL for ImageField
• Django Admin jQuery is upgraded from 1.4.2 to 1.9.1
• New Deployment Check List (https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/)
![Page 64: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/64.jpg)
Notable Changes
![Page 65: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/65.jpg)
• UNUSABLE_PASSWORD is removed (is_password_usable)
• MAXIMUM_PASSWORD_LENGTH is removed in the latest security fix
• Password reset now uses Base64 Encoding (earlier it was base36)
• BooleanField is not default to False (None). Be Explicit
• django.db.models.query.EmptyQuerySet can’t be instantiated
• django-debug-toolbar is breaking
![Page 66: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/66.jpg)
Dropped Features
![Page 67: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/67.jpg)
django.contrib.localflavor
django.contrib.databrowse
django.contrib.markup
![Page 68: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/68.jpg)
Deprecated Features
![Page 69: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/69.jpg)
• django.middleware.transaction.TransactionMiddleware
• django.db.transaction.autocommit
• django.db.transaction.commit_on_success
• django.db.transaction.commit_manually
• TRANSACTIONS_MANAGED (in settings.py)
![Page 70: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/70.jpg)
• CACHE_MIDDLEWARE_ANONYMOUS_ONLY
• SEND_BROKEN_LINK_EMAILS (django.middleware.common.BrokenLinkEmailsMiddleware)
![Page 71: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/71.jpg)
django.contrib.comments
![Page 72: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/72.jpg)
Django 1.7
![Page 73: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/73.jpg)
In built migrations
![Page 75: What's New in Django 1.6](https://reader033.vdocument.in/reader033/viewer/2022051412/54c6abad4a7959ba518b45bb/html5/thumbnails/75.jpg)
References https://docs.djangoproject.com/en/dev/releases/1.6/ https://speakerdeck.com/julienphalip/django-1-dot-6-the-best-new-features-and-the-important-changes