Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's new in Django 1.9

Markus H
September 24, 2015

What's new in Django 1.9

I gave this presentation at the Sydney Django meetup on Nov 24th, 2015.

See the full Django 1.9 release notes for details and all changes: https://docs.djangoproject.com/en/dev/releases/1.9/

Markus H

September 24, 2015
Tweet

More Decks by Markus H

Other Decks in Technology

Transcript

  1. • Django Core Developer • Work at Common Code @m_holtermann

    • github.com/MarkusH • markusholtermann.eu Hi, I’m Markus Holtermann
  2. 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
  3. 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
  4. 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
  5. django.contrib.admin • Changed URL for change view: /admin/<app>/<model>/<pk>/ /admin/<app>/<model>/<pk>/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
  6. django.contrib.postgres • JSONField -- feel free to use in 1.8

    project • TransactionNow database function
  7. 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
  8. Migrations • They got faster again • The squashmigrations command

    now supports specifying the starting migration
  9. 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
  10. Template • Django template loaders can now extend templates recursively

    • The include template tag now caches parsed templates objects during template rendering
  11. 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()
  12. 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
  13. 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