What Is New in Django 3.0
Django 3.0 introduces significant new features and refinements, with a major focus on ASGI support for async programming and expanded database capabilities.
| Category | Key Changes |
|---|---|
| New Features | ASGI support for async, MariaDB support, Exclusion Constraints, Custom enumeration types |
| Improvements | Simplified JSONField usage, New duration expressions, Auto-reloader updates |
| Deprecations | django.contrib.postgres.fields.JSONField is deprecated |
How does Django 3.0 handle ASGI for async support?
Django 3.0 fully embraces asynchronous Python by providing initial support for ASGI (Asynchronous Server Gateway Interface). This is a foundational step towards making the entire framework async-capable.
You can now deploy ASGI applications using django.core.asgi.get_asgi_application(). In practice, this allows you to run Django with async servers like Daphne, enabling support for WebSockets and other async protocols without needing a separate service.
What database improvements are included?
This release expands Django's database ORM with several powerful features. Support for MariaDB 10.2+ is now official, treating it as a first-class MySQL backend.
Exclusion Constraints
PostgreSQL users gain the ExclusionConstraint in model Meta, which prevents two rows from simultaneously satisfying a specified condition.
Custom Enumeration Types
You can now create custom enumeration types (django.contrib.postgres.fields.EnumField) for PostgreSQL, which are more efficient than text choices for fixed sets of values.
How has the JSONField evolved?
The JSONField has been unified and simplified. Previously, PostgreSQL had its own field, but now a built-in models.JSONField is available for all supported databases.
This matters because it streamlines your model definitions. The old django.contrib.postgres.fields.JSONField is deprecated, so you should migrate to the new cross-database field.
What other minor features should I know about?
Several smaller additions enhance day-to-day development. The auto-reloader now works with stat on Python 3.8+ for better performance on macOS.
New duration expressions allow for more complex arithmetic with DurationField. The skipUnlessDBFeature and skipIfDBFeature decorators make it easier to write conditional database tests.
FAQ
Is Django 3.0 fully asynchronous now?
No, the ASGI support is the first step. The core of Django is still synchronous, but this lays the groundwork for async views, middleware, and more in future releases.
Do I have to change my JSONField definitions?
Yes, if you're using the old PostgreSQL-specific django.contrib.postgres.fields.JSONField, you should migrate to the new models.JSONField as the old one is deprecated.
Can I use MariaDB with Django now?
Absolutely. Django 3.0 adds official, supported support for MariaDB 10.2 and higher. You can use it just like the standard MySQL backend.
What Python versions are supported?
Django 3.0 supports Python 3.6, 3.7, and 3.8. It drops support for Python 3.5, so you'll need to upgrade your environment.
How do exclusion constraints work?
They are defined in a model's Meta class and use PostgreSQL's exclusion constraints to prevent overlapping data, like making sure two events don't reserve the same room at the same time.