Django 6.1 was released on August 5, 2026. It is not a rewrite, but three of its changes touch code that almost every production Django project has: how related objects are loaded, how deletes are executed, and how email is configured. All three can remove real problems, and one of them (email) will eventually force a settings migration.
This article covers those three features with examples, then the breaking changes and deprecations worth checking before you upgrade. It is written for developers and technical leads who maintain a Django codebase and want to know whether 6.1 is worth planning for now.
Verification note. The feature list and compatibility details below come from the Django 6.1 release notes source text and search summaries of the official pages. I could not open docs.djangoproject.com from the environment I used for research, and I have not run the code below on Django 6.1. Treat the snippets as illustrations of the documented behaviour and confirm names and import paths against the official 6.1 release notes before using them.
Support window and requirements
According to the release notes, Django 6.1 supports Python 3.12, 3.13 and 3.14, with Python 3.15 added in a later patch release (6.1.3). Mainstream support ends in April 2027 and extended support in December 2027.
The database floor has moved:
| Database | Django 6.1 minimum |
|---|---|
| PostgreSQL | 15 (14 dropped) |
| MySQL | 8.4 |
| MariaDB | 10.11 |
| SQLite | 3.37.0 (was 3.31.0) |
If your Postgres instance is still on 14, the database upgrade is the first task, not the Django one.
Fetch modes: a built-in answer to N+1 queries
The most common Django performance bug is the N+1 query: a loop that touches a related object on each row and runs one query per iteration. The traditional fix is select_related() or prefetch_related(), but you have to remember to add it everywhere, and nothing warns you when you forget.
Django 6.1 adds fetch modes, set per queryset with fetch_mode(). They control what happens when code accesses a field or relation that has not been loaded yet:
FETCH_ONE(the default) loads the missing data for that one instance, as before.FETCH_PEERSloads it for every instance that came from the same queryset, in one query. The release notes describe it as an on-demandprefetch_related().FETCH_RAISEraisesFieldFetchBlocked(fromdjango.core.exceptions), so unintended queries fail loudly.
from django.db import models
books = Book.objects.fetch_mode(models.FETCH_PEERS)
for book in books:
print(book.author.name) # two queries in total, not N + 1
FETCH_PEERS is attractive for existing code: you change one line and the loop collapses to a constant number of queries, with no need to predict which relations a template will touch. FETCH_RAISE is the better tool for tests and strict code paths. Using it on a queryset in a test turns a hidden performance regression into a failing assertion.
Trade-offs to keep in mind:
FETCH_PEERSstill issues queries lazily. An explicitselect_related()that joins in the original query can still be cheaper for relations you always need.- Peers are the instances of that queryset. If you slice, filter in Python or mix instances from several querysets, the batching only covers each original set.
- Custom
Model.from_db()overrides need afetch_modeparameter. Overrides without it are deprecated.
Database-level ON DELETE
ForeignKey.on_delete gains three options that delegate the delete behaviour to the database through the SQL ON DELETE clause: DB_CASCADE, DB_SET_NULL and DB_SET_DEFAULT.
class Comment(models.Model):
post = models.ForeignKey(Post, on_delete=models.DB_CASCADE)
With the existing CASCADE, Django loads the related objects into memory to collect them (and to send signals) before deleting them. With DB_CASCADE, the database does the work in one statement, which is more efficient for large fan-outs.
The catch is documented: DB_CASCADE does not trigger pre_delete or post_delete signals, because Django never sees the child rows. If you rely on signals to clean up files, invalidate caches or write audit entries, keep CASCADE for those relations. Treat this as a per-relation choice, and review each one that has signal receivers before changing it.
Mailers: multiple email backends
Until now Django had one global email configuration made of EMAIL_BACKEND, EMAIL_HOST and friends. 6.1 introduces a MAILERS setting, a dictionary of named mailers, each with its own BACKEND and OPTIONS:
MAILERS = {
"default": {
"BACKEND": "django.core.mail.backends.smtp.EmailBackend",
"OPTIONS": {"host": "smtp.example.com", "use_tls": True},
},
}
You pick a mailer with the using argument on the email-sending functions, or look one up through django.core.mail.mailers[alias]. The practical use is splitting traffic, for example transactional mail through one provider and bulk or internal mail through another, without writing connection-juggling code.
MAILERS is opt-in for now, but it is the direction of travel. The release notes deprecate the EMAIL_* settings, mail.get_connection(), the connection argument, fail_silently, and auth_user/auth_password, and say MAILERS will replace the old settings in Django 2028. Two new system checks help along the way: mail.E001 (a deployment check that blocks non-production backends in default) and mail.W001 (warns when default is missing).
Smaller additions worth knowing
- Database functions and expressions. New
UUID4andUUID7functions, aJSONNullexpression for a JSON scalarnull, andBitAnd,BitOrandBitXoraggregates now in core. - Content Security Policy. A
{% csp_nonce_attr %}template tag, and nonces added to<script>,<style>and<link>elements in built-in and admin templates when the CSP context processor is configured. A newsecurity.W027check was added. - Admin. Actions can appear on the object edit page (
@actiongainslocationanddescription_plural), and the change form gets accessibility improvements. - Security defaults. The PBKDF2 default iteration count rises to 1,500,000, and signed cookies use an unambiguous salt by default.
- Redirects.
RedirectView.preserve_requestkeeps the HTTP method and body using 307/308 redirects. - Tasks.
@taskaccepts extra keyword arguments forwarded totask_class, andTaskandTaskResultcan be pickled.
Upgrade breakages to check first
The release notes list many backwards-incompatible changes. These are the ones most likely to affect an ordinary application:
- Cache keys changed for varied pages and template fragments, so the first request after the upgrade is a cache miss. Expect a brief load spike on a busy site.
- Signed cookies use a new salt. Existing cookies stop validating unless you set
SIGNED_COOKIE_LEGACY_SALT_FALLBACK = True, which is itself deprecated, so use it only as a temporary bridge. - Strict Base64 validation in multipart parsing and database cache decoding means invalid data now raises errors.
- Union queries (
union(),difference(),intersection()) raiseDatabaseErrorif an ordering field is not selected. Callorder_by()with no arguments to clear default ordering. - SQL aliases are quoted, so raw SQL that references mixed-case aliases may need adjusting.
first()andlast()no longer fall back to ordering by primary key afterorder_by()has cleared the ordering.- Email code that passes
fail_silently,auth_userorauth_passwordtogether withconnectionnow raisesTypeError, andEmailMessage.message()raisesValueErrorifBccappears in headers (usebcc). RemoteUserMiddlewareunder ASGI no longer adds anHTTP_prefix to customrequest.METAlookups.- Third-party database backends and admin template overrides have API and markup changes, so check any package that customises either.
checkruns against all databases by default, so it may now connect to databases it previously skipped.
Deprecations to start clearing now include select_related() with no arguments, values_list(flat=True) with no field name, None as a top-level JSON value in JSONField queries (use JSONNull), double-dot template lookups such as {{ book..title }}, and transaction.savepoint() in favour of savepoint_create().
A practical upgrade path
- Upgrade Python and the database to supported versions first.
- Move to the latest 6.0.x and run your tests with warnings enabled (
python -W error::DeprecationWarning) to surface deprecations. - Fix third-party packages that block 6.1. Admin themes and database backends are the usual culprits.
- Upgrade to 6.1 on a staging copy and run the full suite, plus
manage.py check --deploy. - Plan the cache miss and the signed-cookie change for the release window.
- After deploying, adopt features one at a time. Fetch modes in tests are the lowest-risk first step;
DB_CASCADEneeds a signal audit;MAILERScan wait but should be on the roadmap.
Should you upgrade now?
If you are on 6.0, mainstream support for it has ended and security fixes continue until April 2027, so the upgrade is worth scheduling this quarter. If you are on an older long-term release, plan the step through intermediate versions rather than jumping, and budget more time for the deprecation clean-up. The fetch-mode feature alone can pay for the work on any project with slow list pages.
If you want a second pair of eyes on an upgrade or a query-performance review, see my Python, Django and FastAPI development services, or tell me about your project.
FAQ
What is the difference between FETCH_PEERS and prefetch_related()?
prefetch_related() is declared up front and loads the relation for the whole queryset. FETCH_PEERS does the same thing lazily, only when a missing field is first accessed, so you do not need to know in advance which relations will be used.
Does DB_CASCADE replace CASCADE?
No. It is an additional option. It is faster for large deletes but skips pre_delete and post_delete signals, so keep CASCADE where signals matter.
Do I have to migrate to MAILERS now?
No. It is opt-in in 6.1. The old EMAIL_* settings are deprecated and the release notes say they are replaced in Django 2028.
Which Python versions does Django 6.1 support? Python 3.12 to 3.14, with 3.15 supported as of 6.1.3, according to the release notes.
Can I mix this with FastAPI? Yes, and many teams do. See Django vs FastAPI for how to split responsibilities.
References and further reading
- Django 6.1 released, Django weblog
- Django 6.1 release notes
- Django 6.1 release notes source on GitHub
- Upgrade Django: 6.1
- See also: Python 3.15 lazy imports
For the wider framework decision, Django versus FastAPI covers where each one fits, and Python and FastAPI development is the service side. The release notes are at Django’s download page. If you are planning an upgrade and want the breakages checked first, tell me your version.
Conclusion
The 6.1 additions are small and worth taking, but the upgrade path is the real work: read the deprecations, run the test suite against the new version, and check the admin and mailer behaviour before you merge.
Frequently asked questions
Is Django 6.1 a safe upgrade from 6.0?
It is a minor release, so it should be, provided your tests pass. The breakages to look for are the deprecations listed in the release notes, not new features.
What do the new fetch modes change?
They let you express more precisely what a query should load, which reduces both round trips and memory. Adopt them where a query is already known to be heavy, not everywhere.
What is the safest order for a Django upgrade?
Run the test suite against the new version first, then the admin and any custom mailers, then deploy. The failures usually show up in code you wrote rather than in the framework.



