From 7248afe12f40361870388ecdd7e0038eb0d58e47 Mon Sep 17 00:00:00 2001 From: William Schwartz Date: Tue, 30 Mar 2021 15:57:33 -0500 Subject: [PATCH] Refs #32105 -- Moved ExceptionReporter template paths to properties. Refs #32316. --- django/views/debug.py | 10 ++++++++-- docs/howto/error-reporting.txt | 13 +++++++------ docs/releases/3.2.txt | 8 ++++---- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/django/views/debug.py b/django/views/debug.py index 36abaf3121d..1b8637874a0 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -245,8 +245,14 @@ class SafeExceptionReporterFilter: class ExceptionReporter: """Organize and coordinate reporting on exceptions.""" - html_template_path = CURRENT_DIR / 'templates' / 'technical_500.html' - text_template_path = CURRENT_DIR / 'templates' / 'technical_500.txt' + + @property + def html_template_path(self): + return CURRENT_DIR / 'templates' / 'technical_500.html' + + @property + def text_template_path(self): + return CURRENT_DIR / 'templates' / 'technical_500.txt' def __init__(self, request, exc_type, exc_value, tb, is_email=False): self.request = request diff --git a/docs/howto/error-reporting.txt b/docs/howto/error-reporting.txt index 1122f47b1b9..7d5b5baf842 100644 --- a/docs/howto/error-reporting.txt +++ b/docs/howto/error-reporting.txt @@ -323,17 +323,18 @@ Your custom reporter class needs to inherit from .. versionadded:: 3.2 - A :class:`pathlib.Path` representing the absolute filesystem path to a - template for rendering the HTML representation of the exception. - Defaults to the Django provided template. + Property that returns a :class:`pathlib.Path` representing the absolute + filesystem path to a template for rendering the HTML representation of + the exception. Defaults to the Django provided template. .. attribute:: text_template_path .. versionadded:: 3.2 - A :class:`pathlib.Path` representing the absolute filesystem path to a - template for rendering the plain-text representation of the exception. - Defaults to the Django provided template. + Property that returns a :class:`pathlib.Path` representing the absolute + filesystem path to a template for rendering the plain-text + representation of the exception. Defaults to the Django provided + template. .. method:: get_traceback_data() diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt index eebb500202e..3ba8c36415c 100644 --- a/docs/releases/3.2.txt +++ b/docs/releases/3.2.txt @@ -299,10 +299,10 @@ Decorators Error Reporting ~~~~~~~~~~~~~~~ -* Custom :class:`~django.views.debug.ExceptionReporter` subclasses can now set - the :attr:`~django.views.debug.ExceptionReporter.html_template_path` and - :attr:`~django.views.debug.ExceptionReporter.text_template_path` class - attributes to override the templates used to render exception reports. +* Custom :class:`~django.views.debug.ExceptionReporter` subclasses can now + define the :attr:`~django.views.debug.ExceptionReporter.html_template_path` + and :attr:`~django.views.debug.ExceptionReporter.text_template_path` + properties to override the templates used to render exception reports. File Uploads ~~~~~~~~~~~~