What is new in Django 5.0?

Elshad Karimov
2 min readDec 7, 2023

The latest Django release (as of December 4, 2023) is here, and it’s filled with features that are making waves in the web development community. Let’s dive into what Django 5.0 brings to the table, with examples to get you excited:

  1. Facet Filters in Admin: Imagine you’re filtering a list of users in the admin. Now, Django 5.0 shows you how many users fall into each filter category right on the dashboard. Handy for quick insights! 📈
  2. Simplified Template Rendering: Before, rendering a form field involved multiple lines of template code. Now, just use {{ form.name.as_field_group }} and voilà - your form field, complete with label, widget, and help text, is rendered in one line. Clean and efficient! 🎨

Example:

<form>
...
<div>
{{ form.name.as_field_group }}
<div class="row">
<div class="col">{{ form.email.as_field_group }}</div>
<div class="col">{{ form.password.as_field_group }}</div>
</div>
</div>
...
</form>
  1. Database-Computed Default Values: Set a default age for a new user right in your database. For instance, age = models.IntegerField(db_default=18) automatically sets the age to 18 if not provided. 🆕
  2. Database Generated Model Field: Create a model for a square with an area that’s always calculated from its side. Just define area = models.GeneratedField(expression=F("side") * F("side")), and the area updates automatically whenever the side changes. Magic! 🔮
  3. More Flexible Field

--

--

Elshad Karimov

Software Engineer, Udemy Instructor and Book Author, Founder at AppMillers