Django 5.0 Delight: Unraveling the Newest Features
Hello everyone! As 2023 draws to a close, our reasons for celebration extend well beyond the upcoming holidays and vacation. Exciting developments await in the technology realm, including the unveiling of Python 3.12 and the much-anticipated Django 5.0.
This latest release of our Python-based web framework (still the most popular option on the market) signifies a noteworthy advancement that is bound to excite Django enthusiasts everywhere.
204 individuals, in addition to numerous unsung heroes, dedicated their time and efforts to contribute to the launch of Django 5.0. Thanks to each and every one of you! 🙂
Now, let’s explore the remarkable features integrated into this version.
Default values
Django introduced the Field.db_default
parameter, making it possible to have database-computed default values for model fields. This functionality enables you to specify default values that are database-computed.
Generated fields
The new GeneratedField
enables developers to establish database-generated columns within Django models. This field has the ability to calculate its value by leveraging other fields in the model and is applicable across all supported database backends for establishing a field that is consistently computed based on other fields.
In the following illustration, we will concatenate a country code onto a phone number, storing the result in the phone_number_with_ext
column.
Facet filters
Facet counts will be displayed for active filters in the admin change list when activated through the UI toggle. This functionality can be modified using the newly introduced ModelAdmin.show_facets
attribute.
Form field
Django 5.0 introduces the concept of a field group along with field group templates, streamlining the rendering of various components associated with a Django form field, including its label, widget, help text, and errors.
The below example is taken from the official documentation.
This is a much more simplified version.
AsyncClient
Django 5.0 introduces additional asynchronous methods to both the Client and AsyncClient, enabling asynchronous testing of Django applications. This enhancement enables you to create tests that more faithfully replicate the asynchronous behavior of the application.
If you’re feeling fatigued from reading extensive text, take a break and check out this fantastic video crafted by our Developer Advocate Sarah Boyce, where she delves into the remarkable features of Django 5.0.
Conclusion
Django 5.0 marks a significant advancement, bringing enhancements and innovative features that streamline the development journey. This release includes notable improvements in accessibility and asynchronous domains, among other enhancements, the full list of which can be found in the release notes.
If you’re a newcomer to Django and unsure of where to begin, no need to worry: We’ve got you covered with our fantastic tutorials!
What is the Django Web Framework?
We’ll explain all about the Django web framework – an open-source web framework for building web applications using Python. Whether you’re a beginner, an experienced developer, or migrating from a different framework, join us to dive into the details of the Django framework.
Create a Django App in PyCharm
This tutorial will guide you through all the steps involved in creating a simple Django application that shows the current air temperature at your location. To bring in some interactivity, the app also lets you browse weather conditions at other random locations.
Faster Django queries with materialized views
In this blog post, we’re going to talk about materialized views, how and why they help us cut down on query costs, and how to integrate them into your Django application. Read on to learn more or check out this video overview.