What Is New in Django 1.6
Django 1.6 introduces a streamlined database connection management, a simplified project template, and persistent database connections. It's a Long Term Support (LTS) release, making it a stable foundation for long-running projects.
| Category | Key Changes |
|---|---|
| New Features | Simplified project template, Persistent DB connections, Customizable test discovery |
| Improvements | Transaction management overhaul, Faster model object creation |
| Backwards Incompatibilities | New test runner, get_readonly_fields method change |
| Deprecated Features | Django 1.2 style {% url %} syntax, django.contrib.webdesign |
How did database connections get better?
Database connection handling was completely revamped. The old CONN_MAX_AGE setting was replaced with a more robust system for persistent connections.
In practice, this means your application can reuse database connections across requests, which significantly reduces the overhead of establishing a new connection for every single request. This is a big win for performance on high-traffic sites.
Transaction management changes
The default transaction behavior was switched to autocommit. This changes how database transactions are handled, moving away from the implicit "transaction-per-request" model. You now need to explicitly decorate views with @transaction.non_atomic_requests if you don't want them to run in a transaction.
What's new with testing in Django 1.6?
Test discovery got a major upgrade. The new test runner is smarter about finding your tests, so you no longer need to manually add __init__.py files to your tests directories.
You can now customize test discovery by defining a test_runner setting or a run_tests() function in a test_runner module within your app. This gives you much more control over how your test suite is executed.
Did the project template change?
Yes, the default project template was simplified. The old template created multiple files, but the new one starts with a more minimal and modern structure.
It now generates a single settings.py file instead of the previous settings.py, settings_local.py, and urls.py structure. This reduces the initial cognitive load for new developers and aligns better with common deployment practices.
What performance improvements were made?
Model instance creation saw a significant speed boost. The internal machinery for creating model objects was optimized, making operations like MyModel.objects.create() and bulk creates much faster.
This matters because it speeds up data import scripts, fixture loading, and any part of your application that creates a large number of objects. For applications dealing with large datasets, this can cut processing time substantially.
FAQ
Why is Django 1.6 an important version?
It's a Long Term Support (LTS) release, which means it receives security and data loss fixes for an extended period, making it a preferred choice for stable, production applications that can't upgrade frequently.
What's the biggest breaking change I should watch for?
The transaction management change to autocommit mode. If your code relied on the old implicit transaction-per-request behavior, you'll need to explicitly decorate views with @transaction.atomic to maintain the same behavior.
How do persistent database connections work?
Set the CONN_MAX_AGE setting to a positive number of seconds. The database connection will stay open for that duration and be reused for subsequent requests, reducing connection overhead.
Is the old project template style completely gone?
You can still get the old style by using the --template option with django-admin.py startproject and specifying a URL to the old template, but the new simplified template is now the default.
What happened to the {% templatetag openvariable %} url {% templatetag closevariable %} tag syntax?
The pre-Django 1.3 syntax with a dotted path to a view function is now deprecated. You should use the newer syntax that references the URL pattern name instead.