Your SlideShare is downloading. ×
0
What’s New in Django 1.6
Nov 14, 2013

Sivasubramaniam Arunachalam

@sivaa_in

http://www.meetup.com/Bangalore-Django-User...
Malcolm
Tredinnick
(We miss you)
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.9...
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+...
Python 3
Officially Supported
(Enjoy it in Production)
LTS Releases
Django 1.4 till March 2015

https://docs.djangoproject.com/en/dev/internals/release-process/#long-term-suppor...
New Features
•
•
•
•

Simple Layout
Improved Transactions
Persistent DB Connections
Others
New Features
•
•
•
•

Simple Layout
Improved Transactions
Persistent DB Connections
Others
Much&Simpler
(Project App Layouts)
New Defaults
Application - added admin
- removed sites
Middleware - added clickjacking prevention
Database
- SQLite3
Custom Templates
(For Projects & Applications)

https://docs.djangoproject.com/en/1.6/ref/django-admin/#custom-app-and-pro...
startproject
•
•
•
•

manage.py
settings.py
wsgi.py
urls.py
startproject
•
•
•
•

manage.py
settings.py
wsgi.py
urls.py
Removed Settings
•
•
•
•
•

TEMPLATE_DIRS
TEMPLATE_LOADERS

STATIC_ROOT
STATICFILES_DIRS
STATICFILES_FINDERS

•
•

SITE_ID...
Modified Settings
startproject - settings.py
DATABASES
(default to SQLite3)

startproject - settings.py - Modified
TIME_ZONE
(default to UTC)

startproject - settings.py - Modified
INSTALLED_APPS
(admin enabled & sites removed by default)

startproject - settings.py - Modified
MIDDLEWARE_CLASSES
(clickjacking protection is enabled by default)

startproject - settings.py - Modified
New Settings
BASE_DIR

startproject - settings.py
startproject
•
•
•
•

manage.py
settings.py
wsgi.py
urls.py
admin enabled by default

startproject - urls.py
startapp
•
•
•
•

admin.py
models.py
views.py
tests.py
startapp
•
•
•
•

admin.py
models.py
views.py
tests.py
admin.py is generated by default

startapp - admin.py
startapp
•
•
•
•

admin.py
models.py
views.py
tests.py
Default Example TestCase
is removed

startapp - tests.py
File

Django 1.5

Django 1.6

Change

Tar ball

8M

6.6 M

-17.5 %

settings.py

5.3 K

2.0 K

-63.1 %

urls.py

556

297
...
New Features
•
•
•
•

Simple Layout
Improved Transactions
Persistent DB Connections
Others
Improved Transactions
(Biggest Change from 0.9x)
Old APIs were Deprecated

Transactions
New APIs were Introduced

Transactions
Improvements
•
•
•
•

Clean & Simple
Improved Performance
Improved Error Handling
Fine grained rollbacks between
savepoint...
DB Level Auto Commit
• Enabled by default
• Every single SQL Statement is committed immediately

• django.db.transaction.s...
atomic()
• New Single API to control DB transactions

• Commit on Success
• Rollback on Exceptions
• It can be
• Nested
• ...
Decorator

Transactions – New APIs – atomic()
Context Manager

Transactions – New APIs – atomic()
Backward Incompatible
https://docs.djangoproject.com/en/1.6/topics/db/transactions/

#transactions-upgrading-from-1-5

Tra...
More Details
Excellent Presentations by
Aymeric Augustin
https://myks.org/en/talks/

Transactions
New Features
•
•
•
•

Simple Layout
Improved Transactions
Persistent DB Connections
Others
Till Django 1.5
New Connection for every
HTTP Request

Persistent DB Connections
In Django 1.6
Same Connection will be
reused between requests

Persistent DB Connections
CONN_MAX_AGE
•
•
•
•
•

Life Time of a Database Connection
Different for each Database
Default = 0 (Off & No reuse)
For Un...
Processing Behavior
•
•

Connection is established during the first query
Connection won’t be closed and reused for subseq...
New Features
•
•
•
•

Simple Layout
Improved Transactions
Persistent DB Connections
Others
New Test Runner
Locates tests anywhere
(test*.py)
QuerySet.dates() is now Time
Zone Aware
(Earlier Only in UTC)
QuerySet.dates() is now
operates only on DateField()
and returns datetime.date
QuerySet.datetimes() is
operates on DateTimeField()
and returns datetime.datetime

"hour", "minute" or "second“
lookups ar...
BinaryField() is introduced
• Stores raw binary data in bytes
• Queryset is not possible
• Don’t use it to store static fi...
django-admin.py check
• Verifies the setup for Current Version
• Settings
• Application Code
• Warnings will be issued for...
Efficient Model.save()
Before
SELECT is used to determine INSERT (or)
UPDATE
Now
if instance has Primary Key, it is UPDATE...
Model.objects.earliest()
(latest() with reverse direction)
Model.objects.first()
• Returns the first object from QuerySet
• If no order specified, Ordered by PK
• None for EmptyQuer...
Model.objects.first()
Model.objects.last()
Model.objects.filter(timestamp__hour = 23)
Model.objects.filter(timestamp__minute = 59)
Model.objects.filter(timestamp__se...
ModelAdmin.preserve_filters
HTML 5 Types for input fields
(Email, URL and Number)

Supported in
•
•
•
•
•

IntegerField
FloatField
DecimalField
EmailF...
Blank Password is Supported
•
•
•
•
•

SQLite Save Points is supported
Open Layer based GeoDjango Forms API
Pillow is preferred over PIL for ImageFiel...
Notable Changes
•
•
•

UNUSABLE_PASSWORD is removed (is_password_usable)
MAXIMUM_PASSWORD_LENGTH is removed in the latest security fix
Pas...
Dropped Features
django.contrib.localflavor
django.contrib.databrowse
django.contrib.markup
Deprecated Features
•
•
•
•
•

django.middleware.transaction.TransactionMiddleware
django.db.transaction.autocommit
django.db.transaction.comm...
• CACHE_MIDDLEWARE_ANONYMOUS_ONLY
• SEND_BROKEN_LINK_EMAILS
(django.middleware.common.BrokenLinkEmailsMiddleware)
django.contrib.comments
Django 1.7
In built migrations
Thank You!
siva@sivaa.in
bit.ly/sivaa_in

bit.ly/sivasubramaniam
References
https://docs.djangoproject.com/en/dev/releases/1.6/
https://speakerdeck.com/julienphalip/django-1-dot-6-the-bes...
What's New in Django 1.6
What's New in Django 1.6
Upcoming SlideShare
Loading in...5
×

What's New in Django 1.6

8,370

Published on

Presentation used in Bangalore Django User Group Meetup.
http://www.meetup.com/Bangalore-Django-User-Group/events/149839872/

Transcript of "What's New in Django 1.6"

  1. 1. What’s New in Django 1.6 Nov 14, 2013 Sivasubramaniam Arunachalam @sivaa_in http://www.meetup.com/Bangalore-Django-User-Group/events/149839872/
  2. 2. Malcolm Tredinnick (We miss you)
  3. 3. 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
  4. 4. 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
  5. 5. Python 3 Officially Supported (Enjoy it in Production)
  6. 6. LTS Releases Django 1.4 till March 2015 https://docs.djangoproject.com/en/dev/internals/release-process/#long-term-support-lts-releases
  7. 7. New Features • • • • Simple Layout Improved Transactions Persistent DB Connections Others
  8. 8. New Features • • • • Simple Layout Improved Transactions Persistent DB Connections Others
  9. 9. Much&Simpler (Project App Layouts)
  10. 10. New Defaults Application - added admin - removed sites Middleware - added clickjacking prevention Database - SQLite3
  11. 11. Custom Templates (For Projects & Applications) https://docs.djangoproject.com/en/1.6/ref/django-admin/#custom-app-and-project-templates
  12. 12. startproject • • • • manage.py settings.py wsgi.py urls.py
  13. 13. startproject • • • • manage.py settings.py wsgi.py urls.py
  14. 14. Removed Settings • • • • • TEMPLATE_DIRS TEMPLATE_LOADERS STATIC_ROOT STATICFILES_DIRS STATICFILES_FINDERS • • SITE_ID LOGGING • • ADMINS MANAGERS • • MEDIA_ROOT MEDIA_URL startproject - settings.py
  15. 15. Modified Settings startproject - settings.py
  16. 16. DATABASES (default to SQLite3) startproject - settings.py - Modified
  17. 17. TIME_ZONE (default to UTC) startproject - settings.py - Modified
  18. 18. INSTALLED_APPS (admin enabled & sites removed by default) startproject - settings.py - Modified
  19. 19. MIDDLEWARE_CLASSES (clickjacking protection is enabled by default) startproject - settings.py - Modified
  20. 20. New Settings BASE_DIR startproject - settings.py
  21. 21. startproject • • • • manage.py settings.py wsgi.py urls.py
  22. 22. admin enabled by default startproject - urls.py
  23. 23. startapp • • • • admin.py models.py views.py tests.py
  24. 24. startapp • • • • admin.py models.py views.py tests.py
  25. 25. admin.py is generated by default startapp - admin.py
  26. 26. startapp • • • • admin.py models.py views.py tests.py
  27. 27. Default Example TestCase is removed startapp - tests.py
  28. 28. File Django 1.5 Django 1.6 Change Tar ball 8M 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 %
  29. 29. New Features • • • • Simple Layout Improved Transactions Persistent DB Connections Others
  30. 30. Improved Transactions (Biggest Change from 0.9x)
  31. 31. Old APIs were Deprecated Transactions
  32. 32. New APIs were Introduced Transactions
  33. 33. Improvements • • • • Clean & Simple Improved Performance Improved Error Handling Fine grained rollbacks between savepoints Transactions – New APIs
  34. 34. DB Level Auto Commit • Enabled by default • Every single SQL Statement is committed immediately • django.db.transaction.set_autocommit() Transactions – New APIs
  35. 35. atomic() • New Single API to control DB transactions • Commit on Success • Rollback on Exceptions • It can be • Nested • Used as a Decorator & Context Manager Transactions – New APIs
  36. 36. Decorator Transactions – New APIs – atomic()
  37. 37. Context Manager Transactions – New APIs – atomic()
  38. 38. Backward Incompatible https://docs.djangoproject.com/en/1.6/topics/db/transactions/ #transactions-upgrading-from-1-5 Transactions
  39. 39. More Details Excellent Presentations by Aymeric Augustin https://myks.org/en/talks/ Transactions
  40. 40. New Features • • • • Simple Layout Improved Transactions Persistent DB Connections Others
  41. 41. Till Django 1.5 New Connection for every HTTP Request Persistent DB Connections
  42. 42. In Django 1.6 Same Connection will be reused between requests Persistent DB Connections
  43. 43. CONN_MAX_AGE • • • • • 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 Persistent DB Connections
  44. 44. Processing Behavior • • 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 Persistent DB Connections
  45. 45. New Features • • • • Simple Layout Improved Transactions Persistent DB Connections Others
  46. 46. New Test Runner Locates tests anywhere (test*.py)
  47. 47. QuerySet.dates() is now Time Zone Aware (Earlier Only in UTC)
  48. 48. QuerySet.dates() is now operates only on DateField() and returns datetime.date
  49. 49. QuerySet.datetimes() is operates on DateTimeField() and returns datetime.datetime "hour", "minute" or "second“ lookups are supported
  50. 50. BinaryField() is introduced • Stores raw binary data in bytes • Queryset is not possible • Don’t use it to store static files
  51. 51. django-admin.py check • Verifies the setup for Current Version • Settings • Application Code • Warnings will be issued for incompatibles
  52. 52. 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
  53. 53. Model.objects.earliest() (latest() with reverse direction)
  54. 54. Model.objects.first() • Returns the first object from QuerySet • If no order specified, Ordered by PK • None for EmptyQuerySet
  55. 55. Model.objects.first()
  56. 56. Model.objects.last()
  57. 57. Model.objects.filter(timestamp__hour = 23) Model.objects.filter(timestamp__minute = 59) Model.objects.filter(timestamp__second = 59)
  58. 58. ModelAdmin.preserve_filters
  59. 59. HTML 5 Types for input fields (Email, URL and Number) Supported in • • • • • IntegerField FloatField DecimalField EmailField URLField
  60. 60. Blank Password is Supported
  61. 61. • • • • • 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/)
  62. 62. Notable Changes
  63. 63. • • • 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
  64. 64. Dropped Features
  65. 65. django.contrib.localflavor django.contrib.databrowse django.contrib.markup
  66. 66. Deprecated Features
  67. 67. • • • • • django.middleware.transaction.TransactionMiddleware django.db.transaction.autocommit django.db.transaction.commit_on_success django.db.transaction.commit_manually TRANSACTIONS_MANAGED (in settings.py)
  68. 68. • CACHE_MIDDLEWARE_ANONYMOUS_ONLY • SEND_BROKEN_LINK_EMAILS (django.middleware.common.BrokenLinkEmailsMiddleware)
  69. 69. django.contrib.comments
  70. 70. Django 1.7
  71. 71. In built migrations
  72. 72. Thank You! siva@sivaa.in bit.ly/sivaa_in bit.ly/sivasubramaniam
  73. 73. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×