A talk I gave at the San Francisco Django Meetup group
1.7Andrew Godwin@andrewgodwin& you
View Slide
Andrew GodwinAuthor of South migrations libraryHi, I'mAuthor of 1.7 Django migrationsGenerally far too involved in Django
Django 1.7MigrationsScheduled release: May 15th(we'll probably miss it)App loading refactorChecks frameworkselect_related filtersCustom lookups
MigrationsThey're pretty good.
The (second) PlanDjangoSchema backendORM HooksSouth 2Migration handlingUser interfaceBackport for 1.4 - 1.6
Logically SeparateSchema backendORM HooksMigration handlingUser interfaceSchemaEditor Migrations
A New FormatMore conciseDeclarativeIntrospectable
Migration actionsFrozen ORM
In-memory runningCreates models from migration setsAutodetector diffs created from on-diskUsed to feed SchemaEditor / ORM
Backwards CompatabilityAuto-applies first migration if tables existIgnores South-style migrationsSouth will start looking for south_migrations
App LoadingMostly internal changeApp objects per-appStart of long path away from settings
Checks FrameworkProper support for project-level validationOld validation moved inUpgrade warnings now possible
from django.core.checks import register@register()def example_check(app_configs, **kwargs):errors = []# ... your check logic herereturn errors
prefetch_related controlNow accepts a Prefetch objectCan customise order, select_related, or filter
Pizza.objects.prefetch_related(Prefetch('restaurants',queryset=Restaurant.objects.select_related('best_pizza'),))
Custom LookupsAllows for more powerful Field subclassesYou can stop using .extra() and .raw() as much
from django.db.models import Lookupclass 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_paramsreturn '%s <> %s' % (lhs, rhs), params
Important Upgrade Notes
Fields need deconstruct()It's a required new method for all fields.
syncdb is deprecatedUse migrate (old apps will still work)
initial_data is deadUse data migrations and the ORM instead
Django 1.8?LTSMigrations for contrib appsPostgreSQL improvements?
Thanks.@andrewgodwinaeracode.org