Django 1.7 And You

Django 1.7 And You

A talk I gave at the San Francisco Django Meetup group

077e9a0cb34fa3eba2699240c9509717?s=128

Andrew Godwin

April 30, 2014
Tweet

Transcript

  1. 1.7 Andrew Godwin @andrewgodwin & you

  2. Andrew Godwin Author of South migrations library Hi, I'm Author

    of 1.7 Django migrations Generally far too involved in Django
  3. Django 1.7 Migrations Scheduled release: May 15th (we'll probably miss

    it) App loading refactor Checks framework select_related filters Custom lookups
  4. Migrations They're pretty good.

  5. The (second) Plan Django Schema backend ORM Hooks South 2

    Migration handling User interface Backport for 1.4 - 1.6
  6. Logically Separate Schema backend ORM Hooks Migration handling User interface

    SchemaEditor Migrations
  7. A New Format More concise Declarative Introspectable

  8. Migration actions Frozen ORM

  9. None
  10. In-memory running Creates models from migration sets Autodetector diffs created

    from on-disk Used to feed SchemaEditor / ORM
  11. Backwards Compatability Auto-applies first migration if tables exist Ignores South-style

    migrations South will start looking for south_migrations
  12. App Loading Mostly internal change App objects per-app Start of

    long path away from settings
  13. Checks Framework Proper support for project-level validation Old validation moved

    in Upgrade warnings now possible
  14. from django.core.checks import register @register() def example_check(app_configs, **kwargs): errors =

    [] # ... your check logic here return errors
  15. prefetch_related control Now accepts a Prefetch object Can customise order,

    select_related, or filter
  16. Pizza.objects.prefetch_related( Prefetch( 'restaurants', queryset=Restaurant.objects.select_related('best_pizza'), ) )

  17. Custom Lookups Allows for more powerful Field subclasses You can

    stop using .extra() and .raw() as much
  18. from django.db.models import Lookup class NotEqual(Lookup): lookup_name = 'ne' def

    as_sql(self, qn, connection): lhs, lhs_params = self.process_lhs(qn, connection) rhs, rhs_params = self.process_rhs(qn, connection) params = lhs_params + rhs_params return '%s <> %s' % (lhs, rhs), params
  19. Important Upgrade Notes

  20. Fields need deconstruct() It's a required new method for all

    fields.
  21. syncdb is deprecated Use migrate (old apps will still work)

  22. initial_data is dead Use data migrations and the ORM instead

  23. Django 1.8? LTS Migrations for contrib apps PostgreSQL improvements?

  24. Thanks. @andrewgodwin aeracode.org