Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion django/contrib/admindocs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import docutils.core
import docutils.nodes
import docutils.parsers.rst.roles
import docutils.writers
except ImportError:
docutils_is_available = False
else:
Expand Down Expand Up @@ -78,11 +79,14 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None):

.. default-role::
"""
# In docutils < 0.22, the `writer` param must be an instance. Passing a
# string writer name like "html" is only supported in 0.22+.
writer_instance = docutils.writers.get_writer_class("html")()
parts = docutils.core.publish_parts(
source % text,
source_path=thing_being_parsed,
destination_path=None,
writer="html",
writer=writer_instance,
settings_overrides=overrides,
)
return mark_safe(parts["fragment"])
Expand Down
2 changes: 2 additions & 0 deletions docs/releases/5.2.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ Bugfixes
* Fixed a crash in Django 5.2 when validating a model that uses
``GeneratedField`` or constraints composed of ``Q`` and ``Case`` lookups
(:ticket:`36518`).

* Added compatibility for ``docutils`` 0.22 (:ticket:`36535`).
Loading