
Django 5.2 released with model auto-import in shell, composite primary keys support & more
Django has released version 5.2 of its popular Python web framework, introducing several notable features and improvements aimed at enhancing the development process. One of the key enhancements is the updated shell
management command, which now automatically imports models from all installed applications. This change is designed to streamline the development workflow by reducing the need for manual imports, allowing developers to focus more on building their applications.
Another significant feature in Django 5.2 is the introduction of django.db.models.CompositePrimaryKey
. This new addition enables developers to define tables with a primary key composed of multiple fields, a much-requested feature that adds flexibility to database schema design. To implement this, developers can set the pk
attribute to CompositePrimaryKey
when defining a model, simplifying the process of working with complex data relationships.
The latest version also brings improvements in form customization, offering more flexibility in customizing BoundField
. Previously, this required overriding Field.get_bound_field()
, but with the new release, developers can specify attributes like BaseRenderer.bound_field_class
at various levels, including project, form, and field levels.
Alongside these major updates, Django 5.2 includes several minor enhancements and bug fixes, concluding mainstream support for Django 5.1 with the final release of version 5.1.8. Users are encouraged to upgrade to ensure they receive ongoing security updates, as support for Django 5.0 has also ended with the last security release, 5.0.14.