{"title":"Django 5.2.1 release notes","version":"dev","locale":"en","docname":"releases/5.2.1","url":"/en/dev/releases/5.2.1/","canonical":"https://djangodocs.dev/en/dev/releases/5.2.1/","summary":"Django 5.2.1 fixes a security issue with severity “moderate” and several bugs in 5.2.","html":"<h1>Django 5.2.1 release notes<a class=\"heading-anchor\" href=\"#django-5-2-1-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><em>May 7, 2025</em></p>\n<p>Django 5.2.1 fixes a security issue with severity “moderate” and several bugs\nin 5.2.</p>\n<p>This release was built using an upgraded <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/setuptools/\">setuptools</a>, producing\nfilenames compliant with <span class=\"target\" id=\"index-0\"></span><a class=\"pep reference external\" href=\"https://peps.python.org/pep-0491/\"><strong>PEP 491</strong></a> and <span class=\"target\" id=\"index-1\"></span><a class=\"pep reference external\" href=\"https://peps.python.org/pep-0625/\"><strong>PEP 625</strong></a> and thus addressing a PyPI\nwarning about non-compliant distribution filenames. This change only affects\nthe Django packaging process and does not impact Django’s behavior.</p>\n<section id=\"cve-2025-32873-denial-of-service-possibility-in-strip-tags\">\n<h2>CVE-2025-32873: Denial-of-service possibility in <code class=\"docutils literal notranslate\">strip_tags()</code><a class=\"heading-anchor\" href=\"#cve-2025-32873-denial-of-service-possibility-in-strip-tags\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.strip_tags\" title=\"django.utils.html.strip_tags\"><code class=\"xref py py-func docutils literal notranslate\">strip_tags()</code></a> would be slow to evaluate certain inputs\ncontaining large sequences of incomplete HTML tags. This function is used to\nimplement the <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-striptags\"><code class=\"xref std std-tfilter docutils literal notranslate\">striptags</code></a> template filter, which was thus also\nvulnerable.</p>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.strip_tags\" title=\"django.utils.html.strip_tags\"><code class=\"xref py py-func docutils literal notranslate\">strip_tags()</code></a> now raises a <a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.SuspiciousOperation\" title=\"django.core.exceptions.SuspiciousOperation\"><code class=\"xref py py-exc docutils literal notranslate\">SuspiciousOperation</code></a>\nexception if it encounters an unusually large number of unclosed opening tags.</p>\n</section>\n<section id=\"bugfixes\">\n<h2>Bugfixes<a class=\"heading-anchor\" href=\"#bugfixes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<ul class=\"simple\">\n<li><p>Fixed a regression in Django 5.2 that caused a crash when annotating\naggregate expressions over query that uses explicit grouping by transforms\nfollowed by field references (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36292\">#36292</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused unnecessary queries when\nprefetching nullable foreign key relationships (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36290\">#36290</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused a crash of\n<code class=\"docutils literal notranslate\">QuerySet.bulk_create()</code> with nullable geometry fields on PostGIS\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36289\">#36289</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused fields to be incorrectly\nselected when using <code class=\"docutils literal notranslate\">QuerySet.alias()</code> after <code class=\"docutils literal notranslate\">values()</code>\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36299\">#36299</a>).</p></li>\n<li><p>Fixed a data corruption possibility in <code class=\"docutils literal notranslate\">file_move_safe()</code> when\n<code class=\"docutils literal notranslate\">allow_overwrite=True</code>, where leftover content from a previously larger\nfile could remain after overwriting with a smaller one due to lack of\ntruncation (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36298\">#36298</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused a crash when using\n<code class=\"docutils literal notranslate\">QuerySet.select_for_update(of=(…))</code> with <code class=\"docutils literal notranslate\">values()/values_list()</code>\nincluding expressions (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36301\">#36301</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused improper values to be returned\nfrom <code class=\"docutils literal notranslate\">QuerySet.values_list()</code> when duplicate field names were specified\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36288\">#36288</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 where the password validation error message\nfrom <code class=\"docutils literal notranslate\">MinimumLengthValidator</code> was not translated when using non-English\nlocales (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36314\">#36314</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused the <code class=\"docutils literal notranslate\">object-tools</code> block to be\nrendered twice when using custom admin templates with overridden blocks due\nto changes in the base admin page block structure (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36331\">#36331</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2, introduced when fixing <span class=\"target\" id=\"index-2\"></span><a class=\"cve reference external\" href=\"https://www.cve.org/CVERecord?id=CVE-2025-26699\"><strong>CVE 2025-26699</strong></a>,\nwhere the <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-wordwrap\"><code class=\"xref std std-tfilter docutils literal notranslate\">wordwrap</code></a> template filter did not preserve empty lines\nbetween paragraphs after wrapping text (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36341\">#36341</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused a crash when serializing email\nalternatives or attachments due to named tuple mismatches (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36309\">#36309</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused a crash when using <code class=\"docutils literal notranslate\">update()</code>\non a <code class=\"docutils literal notranslate\">QuerySet</code> filtered against a related model and including references\nto annotations through <code class=\"docutils literal notranslate\">values()</code> (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36360\">#36360</a>).</p></li>\n<li><p>Fixed a bug in Django 5.2 that caused composite primary key introspection to\nwrongly identify <code class=\"docutils literal notranslate\">IntegerField</code> as <code class=\"docutils literal notranslate\">AutoField</code> on SQLite\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36358\">#36358</a>).</p></li>\n<li><p>Fixed a bug in Django 5.2 that caused a redundant <code class=\"docutils literal notranslate\">unique_together</code>\nconstraint to be generated for composite primary keys when using\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-inspectdb\"><code class=\"xref std std-djadmin docutils literal notranslate\">inspectdb</code></a> (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36357\">#36357</a>).</p></li>\n</ul>\n</section>","rootId":"django-5-2-1-release-notes","toc":[{"title":"CVE-2025-32873: Denial-of-service possibility in strip_tags()","anchor":"cve-2025-32873-denial-of-service-possibility-in-strip-tags","children":[]},{"title":"Bugfixes","anchor":"bugfixes","children":[]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/5.2.2","title":"Django 5.2.2 release notes","url":"/en/dev/releases/5.2.2/"},"next":{"docname":"releases/5.2","title":"Django 5.2 release notes","url":"/en/dev/releases/5.2/"},"formats":{"html":"/en/dev/releases/5.2.1/","markdown":"/en/dev/releases/5.2.1.md","json":"/en/dev/releases/5.2.1.json"},"source":"https://github.com/django/django/blob/main/docs/releases/5.2.1.txt","official":"https://docs.djangoproject.com/en/dev/releases/5.2.1/","inVersions":["dev","6.1","6.0","5.2"],"inLocales":["en"]}