Backend Development 5 min read

Django 5.0 Released: New Python Compatibility, Field Groups, and Database‑Computed Fields

Django 5.0 has been officially released, adding support for Python 3.10‑3.12, introducing field‑group templates to simplify form rendering, and providing new database‑computed field features such as Field.db_default and GeneratedField, while also marking the end of mainstream support for Django 4.2 and 4.1.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Django 5.0 Released: New Python Compatibility, Field Groups, and Database‑Computed Fields

Django 5.0 is now officially released. It supports the latest Python versions (3.10, 3.11, and 3.12) and recommends using the newest release of each Python branch. Django 4.2.x is the last series to support Python 3.8 and 3.9.

The release introduces field groups and corresponding templates, which simplify the rendering of form fields, labels, help texts, and errors. Example template code shows how a traditional form can be rewritten using the new as_field_group helper.

<code>&lt;form&gt;
... 
&lt;div&gt;
  {{ form.name.label_tag }}
  {% if form.name.help_text %}
    &lt;div class="helptext" id="{{ form.name.id_for_label }}_helptext"&gt;
      {{ form.name.help_text|safe }}
    &lt;/div&gt;
  {% endif %}
  {{ form.name.errors }}
  {{ form.name }}
&lt;/div&gt;
... 
&lt;/form&gt;</code>

With field groups the same form can be reduced to:

<code>&lt;form&gt;
... 
&lt;div&gt;
  {{ form.name.as_field_group }}
  &lt;div class="row"&gt;
    &lt;div class="col"&gt;{{ form.email.as_field_group }}&lt;/div&gt;
    &lt;div class="col"&gt;{{ form.password.as_field_group }}&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
... 
&lt;/form&gt;</code>

Two new database‑related field options are added:

Field.db_default allows setting a database‑computed default value (e.g., age = models.IntegerField(db_default=18) ).

GeneratedField creates columns whose values are always calculated from other fields (e.g., area = models.GeneratedField(expression=F('side') * F('side'), db_persist=True) ).

Django 5.0 release notes can be found at https://docs.djangoproject.com/en/5.0/releases/5.0/ . With this release, Django 4.2 has entered its final maintenance phase (last bug‑fix version 4.2.8 released), and extended support for Django 4.1 has also ended, urging users to upgrade.

Related links:

Django 5.0 released announcement

Django 5.0 bug‑fix release

Pythonbackend developmentDjangoWeb FrameworkDatabase Computed FieldsField Group
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.