Slide 1

Slide 1 text

What’s new in Django 1.9

Slide 2

Slide 2 text

• Django Core Developer • Work at Common Code @m_holtermann • github.com/MarkusH • markusholtermann.eu Hi, I’m Markus Holtermann

Slide 3

Slide 3 text

Python Support • 2.7, 3.4, 3.5 • 3.2 and 3.3 has been dropped

Slide 4

Slide 4 text

Password Validation • settings.AUTH_PASSWORD_VALIDATORS • Built-in: ० minimum length ० compare to user attributes ० common passwords ० not only numeric • Validators support additional options: ० e.g. change minimum length • Documentation: https://goo.gl/dCLxE3

Slide 5

Slide 5 text

Permissions on CBV • AccessMixin • LoginRequiredMixin • PermissionRequiredMixin • UserPassesTestMixin from django.contrib.auth.mixins import PermissionRequiredMixin class MyView(PermissionRequiredMixin, View): permission_required = 'polls.can_vote' # Or multiple of permissions: permission_required = ('polls.can_open', 'polls.can_edit') • Documentation: https://goo.gl/qW5LaI • Taken from django-braces

Slide 6

Slide 6 text

on_commit Signal • Send signal after a successful transaction commit with transaction.atomic(): transaction.on_commit(foo) with transaction.atomic(): transaction.on_commit(bar) • Documentation: https://goo.gl/BhXUsF • Taken from django-transaction-hooks

Slide 7

Slide 7 text

New Style for contrib.admin • Taken from django-flat-theme

Slide 8

Slide 8 text

django.contrib.admin • Changed URL for change view: /admin//// /admin////change/ • The time picker widget includes a “6 pm” option • Added jQuery events when an inline form is added or removed on the change form page

Slide 9

Slide 9 text

django.contrib.auth • AbstractBaseUser and BaseUserManager moved to django.contrib.auth.base_user

Slide 10

Slide 10 text

django.contrib.postgres • JSONField -- feel free to use in 1.8 project • TransactionNow database function

Slide 11

Slide 11 text

Forms • ModelForms.meta now has field_classes attribute • Change ordering of fields with field_order attribute or order_fields() method • SlugField now has has an allow_unicode attribute

Slide 12

Slide 12 text

Migrations • They got faster again • The squashmigrations command now supports specifying the starting migration

Slide 13

Slide 13 text

Models & Database Backends • django.db.backends.postgresql_psycopg2 was renamed to django.db.backends.postgresql • keep_parents parameter to Model.delete() for multi-table inheritance • Model.delete() and QuerySet.delete() return the number of objects deleted • Date/time lookups can be chained with lookups: Entry.objects.filter (pub_date__month__gt=6) • There is a Now() database function

Slide 14

Slide 14 text

Template • Django template loaders can now extend templates recursively • The include template tag now caches parsed templates objects during template rendering

Slide 15

Slide 15 text

Django Development Process • runtest.py --parallel

Slide 16

Slide 16 text

Backwards Incompatible Changes • mymodel.m2m = [other1, other2] is no longer clear() and add() • simple_tag now wraps tag output in conditional_escape • Implicit QuerySet __in lookup removed for related query sets • Form initialization was moved from ProcessFormView.get() to FormMixin. get_context_data()

Slide 17

Slide 17 text

Features removed in 1.9 • django.utils.unittest • syncdb and related signals and router methods are removed • No apps w/o migrations unless --run-syncdb is passed to migrate • All models need to be defined inside an installed application or declare an explicit app_label • The default value of the RedirectView. permanent attribute has changed from True to False

Slide 18

Slide 18 text

Outlook • Beta mid October • Release Candidate mid November • Final beginning Dezember • 1.10 -- August 2016 • 1.11 (LTS) -- April 2017 • 2.0 -- Dezember 2017 -- Python 3 only

Slide 19

Slide 19 text

Thank You! @m_holtermann • github.com/MarkusH • markusholtermann.eu