Django 4.1: New Features for Handling Geometries

Django 4.1 brings two new features for handling geographic geometries; allowing developers to create valid and canonical geometries more easily:

  • GEOSGeometry.make_valid() returns a valid representation of a geometry. Unless the geometry is already valid, then the geometry is returned without changes. The function is very similar to ST_MakeValid in PostGIS.
  • GEOSGeometry.normalize() returns the canonical, or standardised, representation of a geometry. The method now accepts the optional clone keyword indicating that the normalisation must not change the geometry and instead return a new geometry object.

Additionally, support for GDAL 2.1 and PostGIS 2.4 has been removed, and the Django Admin’s OpenLayersWidget is now deprecated.

Check the release notes for all other changes in Django 4.1.