{"title":"How to manage error reporting","version":"5.2","locale":"en","docname":"howto/error-reporting","url":"/en/5.2/howto/error-reporting/","canonical":"https://djangodocs.dev/en/5.2/howto/error-reporting/","summary":"When you’re running a public site you should always turn off the DEBUG setting. That will make your server run much faster, and will also prevent malicious users…","html":"<h1>How to manage error reporting<a class=\"heading-anchor\" href=\"#how-to-manage-error-reporting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>When you’re running a public site you should always turn off the\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> setting. That will make your server run much faster, and will\nalso prevent malicious users from seeing details of your application that can be\nrevealed by the error pages.</p>\n<p>However, running with <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> set to <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code> means you’ll never see\nerrors generated by your site – everyone will instead see your public error\npages. You need to keep track of errors that occur in deployed sites, so Django\ncan be configured to create reports with details about those errors.</p>\n<section id=\"email-reports\">\n<h2>Email reports<a class=\"heading-anchor\" href=\"#email-reports\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"server-errors\">\n<h3>Server errors<a class=\"heading-anchor\" href=\"#server-errors\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code>, Django will email the users listed in the\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-ADMINS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ADMINS</span></code></a> setting whenever your code raises an unhandled exception and\nresults in an internal server error (strictly speaking, for any response with\nan HTTP status code of 500 or greater). This gives the administrators immediate\nnotification of any errors. The <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-ADMINS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ADMINS</span></code></a> will get a description of the\nerror, a complete Python traceback, and details about the HTTP request that\ncaused the error.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>In order to send email, Django requires a few settings telling it\nhow to connect to your mail server. At the very least, you’ll need\nto specify <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-EMAIL_HOST\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">EMAIL_HOST</span></code></a> and possibly\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-EMAIL_HOST_USER\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">EMAIL_HOST_USER</span></code></a> and <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-EMAIL_HOST_PASSWORD\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">EMAIL_HOST_PASSWORD</span></code></a>,\nthough other settings may be also required depending on your mail\nserver’s configuration. Consult <a class=\"reference internal\" href=\"/en/5.2/ref/settings/\"><span class=\"doc\">the Django settings\ndocumentation</span></a> for a full list of email-related\nsettings.</p>\n</aside>\n<p>By default, Django will send email from <a class=\"reference external\" href=\"mailto:root&#37;&#52;&#48;localhost\">root<span>&#64;</span>localhost</a>. However, some mail\nproviders reject all email from this address. To use a different sender\naddress, modify the <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-SERVER_EMAIL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">SERVER_EMAIL</span></code></a> setting.</p>\n<p>To activate this behavior, put the email addresses of the recipients in the\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-ADMINS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ADMINS</span></code></a> setting.</p>\n<aside class=\"admonition admonition-seealso\">\n<p class=\"admonition-title\">See also</p>\n<p>Server error emails are sent using the logging framework, so you can\ncustomize this behavior by <a class=\"reference internal\" href=\"/en/5.2/topics/logging/\"><span class=\"doc\">customizing your logging configuration</span></a>.</p>\n</aside>\n</section>\n<section id=\"errors\">\n<h3>404 errors<a class=\"heading-anchor\" href=\"#errors\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django can also be configured to email errors about broken links (404 “page\nnot found” errors). Django sends emails about 404 errors when:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code>;</p></li>\n<li><p>Your <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MIDDLEWARE</span></code></a> setting includes\n<a class=\"reference internal\" href=\"/en/5.2/ref/middleware/#django.middleware.common.BrokenLinkEmailsMiddleware\" title=\"django.middleware.common.BrokenLinkEmailsMiddleware\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">django.middleware.common.BrokenLinkEmailsMiddleware</span></code></a>.</p></li>\n</ul>\n<p>If those conditions are met, Django will email the users listed in the\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-MANAGERS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MANAGERS</span></code></a> setting whenever your code raises a 404 and the request has\na referer. It doesn’t bother to email for 404s that don’t have a referer –\nthose are usually people typing in broken URLs or broken web bots. It also\nignores 404s when the referer is equal to the requested URL, since this\nbehavior is from broken web bots too.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p><a class=\"reference internal\" href=\"/en/5.2/ref/middleware/#django.middleware.common.BrokenLinkEmailsMiddleware\" title=\"django.middleware.common.BrokenLinkEmailsMiddleware\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">BrokenLinkEmailsMiddleware</span></code></a> must appear\nbefore other middleware that intercepts 404 errors, such as\n<a class=\"reference internal\" href=\"/en/5.2/ref/middleware/#django.middleware.locale.LocaleMiddleware\" title=\"django.middleware.locale.LocaleMiddleware\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">LocaleMiddleware</span></code></a> or\n<a class=\"reference internal\" href=\"/en/5.2/ref/contrib/flatpages/#django.contrib.flatpages.middleware.FlatpageFallbackMiddleware\" title=\"django.contrib.flatpages.middleware.FlatpageFallbackMiddleware\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">FlatpageFallbackMiddleware</span></code></a>.\nPut it toward the top of your <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MIDDLEWARE</span></code></a> setting.</p>\n</aside>\n<p>You can tell Django to stop reporting particular 404s by tweaking the\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-IGNORABLE_404_URLS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">IGNORABLE_404_URLS</span></code></a> setting. It should be a list of compiled\nregular expression objects. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">import</span><span class=\"w\"> </span><span class=\"nn\">re</span>\n\n<span class=\"n\">IGNORABLE_404_URLS</span> <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"n\">re</span><span class=\"o\">.</span><span class=\"n\">compile</span><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;\\.(php|cgi)$&quot;</span><span class=\"p\">),</span>\n    <span class=\"n\">re</span><span class=\"o\">.</span><span class=\"n\">compile</span><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^/phpmyadmin/&quot;</span><span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>In this example, a 404 to any URL ending with <code class=\"docutils literal notranslate\"><span class=\"pre\">.php</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">.cgi</span></code> will <em>not</em> be\nreported. Neither will any URL starting with <code class=\"docutils literal notranslate\"><span class=\"pre\">/phpmyadmin/</span></code>.</p>\n<p>The following example shows how to exclude some conventional URLs that browsers and\ncrawlers often request:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">import</span><span class=\"w\"> </span><span class=\"nn\">re</span>\n\n<span class=\"n\">IGNORABLE_404_URLS</span> <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"n\">re</span><span class=\"o\">.</span><span class=\"n\">compile</span><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^/apple-touch-icon.*\\.png$&quot;</span><span class=\"p\">),</span>\n    <span class=\"n\">re</span><span class=\"o\">.</span><span class=\"n\">compile</span><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^/favicon\\.ico$&quot;</span><span class=\"p\">),</span>\n    <span class=\"n\">re</span><span class=\"o\">.</span><span class=\"n\">compile</span><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^/robots\\.txt$&quot;</span><span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>(Note that these are regular expressions, so we put a backslash in front of\nperiods to escape them.)</p>\n<p>If you’d like to customize the behavior of\n<a class=\"reference internal\" href=\"/en/5.2/ref/middleware/#django.middleware.common.BrokenLinkEmailsMiddleware\" title=\"django.middleware.common.BrokenLinkEmailsMiddleware\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">django.middleware.common.BrokenLinkEmailsMiddleware</span></code></a> further (for\nexample to ignore requests coming from web crawlers), you should subclass it\nand override its methods.</p>\n<aside class=\"admonition admonition-seealso\">\n<p class=\"admonition-title\">See also</p>\n<p>404 errors are logged using the logging framework. By default, these log\nrecords are ignored, but you can use them for error reporting by writing a\nhandler and <a class=\"reference internal\" href=\"/en/5.2/topics/logging/\"><span class=\"doc\">configuring logging</span></a> appropriately.</p>\n</aside>\n</section>\n</section>\n<section id=\"filtering-error-reports\">\n<span id=\"id1\"></span><h2>Filtering error reports<a class=\"heading-anchor\" href=\"#filtering-error-reports\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Warning</p>\n<p>Filtering sensitive data is a hard problem, and it’s nearly impossible to\nguarantee that sensitive data won’t leak into an error report. Therefore,\nerror reports should only be available to trusted team members and you\nshould avoid transmitting error reports unencrypted over the internet\n(such as through email).</p>\n</aside>\n<section id=\"filtering-sensitive-information\">\n<h3>Filtering sensitive information<a class=\"heading-anchor\" href=\"#filtering-sensitive-information\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Error reports are really helpful for debugging errors, so it is generally\nuseful to record as much relevant information about those errors as possible.\nFor example, by default Django records the <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Stack_trace\">full traceback</a> for the\nexception raised, each <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Stack_frame\">traceback frame</a>’s local variables, and the\n<a class=\"reference internal\" href=\"/en/5.2/ref/request-response/#django.http.HttpRequest\" title=\"django.http.HttpRequest\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">HttpRequest</span></code></a>’s <a class=\"reference internal\" href=\"/en/5.2/ref/request-response/#httprequest-attributes\"><span class=\"std std-ref\">attributes</span></a>.</p>\n<p>However, sometimes certain types of information may be too sensitive and thus\nmay not be appropriate to be kept track of, for example a user’s password or\ncredit card number. So in addition to filtering out settings that appear to be\nsensitive as described in the <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> documentation, Django offers a\nset of function decorators to help you control which information should be\nfiltered out of error reports in a production environment (that is, where\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> is set to <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code>): <a class=\"reference internal\" href=\"#django.views.decorators.debug.sensitive_variables\" title=\"django.views.decorators.debug.sensitive_variables\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">sensitive_variables()</span></code></a> and\n<a class=\"reference internal\" href=\"#django.views.decorators.debug.sensitive_post_parameters\" title=\"django.views.decorators.debug.sensitive_post_parameters\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">sensitive_post_parameters()</span></code></a>.</p>\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.views.decorators.debug.sensitive_variables\">\n<span class=\"sig-name descname\"><span class=\"pre\">sensitive_variables</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">*</span></span><span class=\"n\"><span class=\"pre\">variables</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.views.decorators.debug.sensitive_variables\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>If a function (either a view or any regular callback) in your code uses\nlocal variables susceptible to contain sensitive information, you may\nprevent the values of those variables from being included in error reports\nusing the <code class=\"docutils literal notranslate\"><span class=\"pre\">sensitive_variables</span></code> decorator:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.views.decorators.debug</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">sensitive_variables</span>\n\n\n<span class=\"nd\">@sensitive_variables</span><span class=\"p\">(</span><span class=\"s2\">&quot;user&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;pw&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;cc&quot;</span><span class=\"p\">)</span>\n<span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">process_info</span><span class=\"p\">(</span><span class=\"n\">user</span><span class=\"p\">):</span>\n    <span class=\"n\">pw</span> <span class=\"o\">=</span> <span class=\"n\">user</span><span class=\"o\">.</span><span class=\"n\">pass_word</span>\n    <span class=\"n\">cc</span> <span class=\"o\">=</span> <span class=\"n\">user</span><span class=\"o\">.</span><span class=\"n\">credit_card_number</span>\n    <span class=\"n\">name</span> <span class=\"o\">=</span> <span class=\"n\">user</span><span class=\"o\">.</span><span class=\"n\">name</span>\n    <span class=\"o\">...</span>\n</code></pre></div>\n<p>In the above example, the values for the <code class=\"docutils literal notranslate\"><span class=\"pre\">user</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">pw</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">cc</span></code>\nvariables will be hidden and replaced with stars (<code class=\"docutils literal notranslate\"><span class=\"pre\">**********</span></code>)\nin the error reports, whereas the value of the <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code> variable will be\ndisclosed.</p>\n<p>To systematically hide all local variables of a function from error logs,\ndo not provide any argument to the <code class=\"docutils literal notranslate\"><span class=\"pre\">sensitive_variables</span></code> decorator:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"nd\">@sensitive_variables</span><span class=\"p\">()</span>\n<span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">my_function</span><span class=\"p\">():</span> <span class=\"o\">...</span>\n</code></pre></div>\n<aside class=\"admonition-when-using-multiple-decorators admonition\">\n<p class=\"admonition-title\">When using multiple decorators</p>\n<p>If the variable you want to hide is also a function argument (e.g.\n‘<code class=\"docutils literal notranslate\"><span class=\"pre\">user</span></code>’ in the following example), and if the decorated function has\nmultiple decorators, then make sure to place <code class=\"docutils literal notranslate\"><span class=\"pre\">&#64;sensitive_variables</span></code>\nat the top of the decorator chain. This way it will also hide the\nfunction argument as it gets passed through the other decorators:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"nd\">@sensitive_variables</span><span class=\"p\">(</span><span class=\"s2\">&quot;user&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;pw&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;cc&quot;</span><span class=\"p\">)</span>\n<span class=\"nd\">@some_decorator</span>\n<span class=\"nd\">@another_decorator</span>\n<span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">process_info</span><span class=\"p\">(</span><span class=\"n\">user</span><span class=\"p\">):</span> <span class=\"o\">...</span>\n</code></pre></div>\n</aside>\n</dd></dl>\n\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.views.decorators.debug.sensitive_post_parameters\">\n<span class=\"sig-name descname\"><span class=\"pre\">sensitive_post_parameters</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">*</span></span><span class=\"n\"><span class=\"pre\">parameters</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.views.decorators.debug.sensitive_post_parameters\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>If one of your views receives an <a class=\"reference internal\" href=\"/en/5.2/ref/request-response/#django.http.HttpRequest\" title=\"django.http.HttpRequest\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">HttpRequest</span></code></a> object\nwith <a class=\"reference internal\" href=\"/en/5.2/ref/request-response/#django.http.HttpRequest.POST\" title=\"django.http.HttpRequest.POST\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">POST</span> <span class=\"pre\">parameters</span></code></a> susceptible to\ncontain sensitive information, you may prevent the values of those\nparameters from being included in the error reports using the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">sensitive_post_parameters</span></code> decorator:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.views.decorators.debug</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">sensitive_post_parameters</span>\n\n\n<span class=\"nd\">@sensitive_post_parameters</span><span class=\"p\">(</span><span class=\"s2\">&quot;pass_word&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;credit_card_number&quot;</span><span class=\"p\">)</span>\n<span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">record_user_profile</span><span class=\"p\">(</span><span class=\"n\">request</span><span class=\"p\">):</span>\n    <span class=\"n\">UserProfile</span><span class=\"o\">.</span><span class=\"n\">create</span><span class=\"p\">(</span>\n        <span class=\"n\">user</span><span class=\"o\">=</span><span class=\"n\">request</span><span class=\"o\">.</span><span class=\"n\">user</span><span class=\"p\">,</span>\n        <span class=\"n\">password</span><span class=\"o\">=</span><span class=\"n\">request</span><span class=\"o\">.</span><span class=\"n\">POST</span><span class=\"p\">[</span><span class=\"s2\">&quot;pass_word&quot;</span><span class=\"p\">],</span>\n        <span class=\"n\">credit_card</span><span class=\"o\">=</span><span class=\"n\">request</span><span class=\"o\">.</span><span class=\"n\">POST</span><span class=\"p\">[</span><span class=\"s2\">&quot;credit_card_number&quot;</span><span class=\"p\">],</span>\n        <span class=\"n\">name</span><span class=\"o\">=</span><span class=\"n\">request</span><span class=\"o\">.</span><span class=\"n\">POST</span><span class=\"p\">[</span><span class=\"s2\">&quot;name&quot;</span><span class=\"p\">],</span>\n    <span class=\"p\">)</span>\n    <span class=\"o\">...</span>\n</code></pre></div>\n<p>In the above example, the values for the <code class=\"docutils literal notranslate\"><span class=\"pre\">pass_word</span></code> and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">credit_card_number</span></code> POST parameters will be hidden and replaced with\nstars (<code class=\"docutils literal notranslate\"><span class=\"pre\">**********</span></code>) in the request’s representation inside the\nerror reports, whereas the value of the <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code> parameter will be\ndisclosed.</p>\n<p>To systematically hide all POST parameters of a request in error reports,\ndo not provide any argument to the <code class=\"docutils literal notranslate\"><span class=\"pre\">sensitive_post_parameters</span></code> decorator:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"nd\">@sensitive_post_parameters</span><span class=\"p\">()</span>\n<span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">my_view</span><span class=\"p\">(</span><span class=\"n\">request</span><span class=\"p\">):</span> <span class=\"o\">...</span>\n</code></pre></div>\n<p>All POST parameters are systematically filtered out of error reports for\ncertain <a class=\"reference internal\" href=\"/en/5.2/topics/auth/default/#module-django.contrib.auth.views\" title=\"django.contrib.auth.views\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">django.contrib.auth.views</span></code></a> views (<code class=\"docutils literal notranslate\"><span class=\"pre\">login</span></code>,\n<code class=\"docutils literal notranslate\"><span class=\"pre\">password_reset_confirm</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">password_change</span></code>, and <code class=\"docutils literal notranslate\"><span class=\"pre\">add_view</span></code> and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">user_change_password</span></code> in the <code class=\"docutils literal notranslate\"><span class=\"pre\">auth</span></code> admin) to prevent the leaking of\nsensitive information such as user passwords.</p>\n</dd></dl>\n\n</section>\n<section id=\"custom-error-reports\">\n<span id=\"id2\"></span><h3>Custom error reports<a class=\"heading-anchor\" href=\"#custom-error-reports\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>All <a class=\"reference internal\" href=\"#django.views.decorators.debug.sensitive_variables\" title=\"django.views.decorators.debug.sensitive_variables\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">sensitive_variables()</span></code></a> and <a class=\"reference internal\" href=\"#django.views.decorators.debug.sensitive_post_parameters\" title=\"django.views.decorators.debug.sensitive_post_parameters\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">sensitive_post_parameters()</span></code></a> do is,\nrespectively, annotate the decorated function with the names of sensitive\nvariables and annotate the <code class=\"docutils literal notranslate\"><span class=\"pre\">HttpRequest</span></code> object with the names of sensitive\nPOST parameters, so that this sensitive information can later be filtered out\nof reports when an error occurs. The actual filtering is done by Django’s\ndefault error reporter filter:\n<a class=\"reference internal\" href=\"#django.views.debug.SafeExceptionReporterFilter\" title=\"django.views.debug.SafeExceptionReporterFilter\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">django.views.debug.SafeExceptionReporterFilter</span></code></a>. This filter uses the\ndecorators’ annotations to replace the corresponding values with stars\n(<code class=\"docutils literal notranslate\"><span class=\"pre\">**********</span></code>) when the error reports are produced. If you wish to\noverride or customize this default behavior for your entire site, you need to\ndefine your own filter class and tell Django to use it via the\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEFAULT_EXCEPTION_REPORTER_FILTER\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEFAULT_EXCEPTION_REPORTER_FILTER</span></code></a> setting:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">DEFAULT_EXCEPTION_REPORTER_FILTER</span> <span class=\"o\">=</span> <span class=\"s2\">&quot;path.to.your.CustomExceptionReporterFilter&quot;</span>\n</code></pre></div>\n<p>You may also control in a more granular way which filter to use within any\ngiven view by setting the <code class=\"docutils literal notranslate\"><span class=\"pre\">HttpRequest</span></code>’s <code class=\"docutils literal notranslate\"><span class=\"pre\">exception_reporter_filter</span></code>\nattribute:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">my_view</span><span class=\"p\">(</span><span class=\"n\">request</span><span class=\"p\">):</span>\n    <span class=\"k\">if</span> <span class=\"n\">request</span><span class=\"o\">.</span><span class=\"n\">user</span><span class=\"o\">.</span><span class=\"n\">is_authenticated</span><span class=\"p\">:</span>\n        <span class=\"n\">request</span><span class=\"o\">.</span><span class=\"n\">exception_reporter_filter</span> <span class=\"o\">=</span> <span class=\"n\">CustomExceptionReporterFilter</span><span class=\"p\">()</span>\n    <span class=\"o\">...</span>\n</code></pre></div>\n<p>Your custom filter class needs to inherit from\n<a class=\"reference internal\" href=\"#django.views.debug.SafeExceptionReporterFilter\" title=\"django.views.debug.SafeExceptionReporterFilter\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">django.views.debug.SafeExceptionReporterFilter</span></code></a> and may override the\nfollowing attributes and methods:</p>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.SafeExceptionReporterFilter\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">SafeExceptionReporterFilter</span></span><a class=\"heading-anchor\" href=\"#django.views.debug.SafeExceptionReporterFilter\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.SafeExceptionReporterFilter.cleansed_substitute\">\n<span class=\"sig-name descname\"><span class=\"pre\">cleansed_substitute</span></span><a class=\"heading-anchor\" href=\"#django.views.debug.SafeExceptionReporterFilter.cleansed_substitute\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The string value to replace sensitive value with. By default it\nreplaces the values of sensitive variables with stars\n(<code class=\"docutils literal notranslate\"><span class=\"pre\">**********</span></code>).</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.SafeExceptionReporterFilter.hidden_settings\">\n<span class=\"sig-name descname\"><span class=\"pre\">hidden_settings</span></span><a class=\"heading-anchor\" href=\"#django.views.debug.SafeExceptionReporterFilter.hidden_settings\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>A compiled regular expression object used to match settings and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">request.META</span></code> values considered as sensitive. By default equivalent\nto:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">import</span><span class=\"w\"> </span><span class=\"nn\">re</span>\n\n<span class=\"n\">re</span><span class=\"o\">.</span><span class=\"n\">compile</span><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;API|AUTH|TOKEN|KEY|SECRET|PASS|SIGNATURE|HTTP_COOKIE&quot;</span><span class=\"p\">,</span> <span class=\"n\">flags</span><span class=\"o\">=</span><span class=\"n\">re</span><span class=\"o\">.</span><span class=\"n\">IGNORECASE</span><span class=\"p\">)</span>\n</code></pre></div>\n<aside class=\"version-note version-changed\" data-version=\"5.2\">\n<p class=\"version-note-title\">Changed in Django 5.2</p><p>The term <code class=\"docutils literal notranslate\"><span class=\"pre\">AUTH</span></code> was added.</p>\n</aside>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.SafeExceptionReporterFilter.is_active\">\n<span class=\"sig-name descname\"><span class=\"pre\">is_active</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">request</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.views.debug.SafeExceptionReporterFilter.is_active\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code> to activate the filtering in\n<a class=\"reference internal\" href=\"#django.views.debug.SafeExceptionReporterFilter.get_post_parameters\" title=\"django.views.debug.SafeExceptionReporterFilter.get_post_parameters\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">get_post_parameters()</span></code></a> and <a class=\"reference internal\" href=\"#django.views.debug.SafeExceptionReporterFilter.get_traceback_frame_variables\" title=\"django.views.debug.SafeExceptionReporterFilter.get_traceback_frame_variables\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">get_traceback_frame_variables()</span></code></a>.\nBy default the filter is active if <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code>. Note\nthat sensitive <code class=\"docutils literal notranslate\"><span class=\"pre\">request.META</span></code> values are always filtered along with\nsensitive setting values, as described in the <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a>\ndocumentation.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.SafeExceptionReporterFilter.get_post_parameters\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_post_parameters</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">request</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.views.debug.SafeExceptionReporterFilter.get_post_parameters\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns the filtered dictionary of POST parameters. Sensitive values\nare replaced with <a class=\"reference internal\" href=\"#django.views.debug.SafeExceptionReporterFilter.cleansed_substitute\" title=\"django.views.debug.SafeExceptionReporterFilter.cleansed_substitute\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">cleansed_substitute</span></code></a>.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.SafeExceptionReporterFilter.get_traceback_frame_variables\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_traceback_frame_variables</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">request</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">tb_frame</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.views.debug.SafeExceptionReporterFilter.get_traceback_frame_variables\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns the filtered dictionary of local variables for the given\ntraceback frame. Sensitive values are replaced with\n<a class=\"reference internal\" href=\"#django.views.debug.SafeExceptionReporterFilter.cleansed_substitute\" title=\"django.views.debug.SafeExceptionReporterFilter.cleansed_substitute\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">cleansed_substitute</span></code></a>.</p>\n</dd></dl>\n\n</dd></dl>\n\n<p>If you need to customize error reports beyond filtering you may specify a\ncustom error reporter class by defining the\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEFAULT_EXCEPTION_REPORTER\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEFAULT_EXCEPTION_REPORTER</span></code></a> setting:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">DEFAULT_EXCEPTION_REPORTER</span> <span class=\"o\">=</span> <span class=\"s2\">&quot;path.to.your.CustomExceptionReporter&quot;</span>\n</code></pre></div>\n<p>The exception reporter is responsible for compiling the exception report data,\nand formatting it as text or HTML appropriately. (The exception reporter uses\n<a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEFAULT_EXCEPTION_REPORTER_FILTER\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEFAULT_EXCEPTION_REPORTER_FILTER</span></code></a> when preparing the exception\nreport data.)</p>\n<p>Your custom reporter class needs to inherit from\n<a class=\"reference internal\" href=\"#django.views.debug.ExceptionReporter\" title=\"django.views.debug.ExceptionReporter\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">django.views.debug.ExceptionReporter</span></code></a>.</p>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.ExceptionReporter\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">ExceptionReporter</span></span><a class=\"heading-anchor\" href=\"#django.views.debug.ExceptionReporter\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.ExceptionReporter.html_template_path\">\n<span class=\"sig-name descname\"><span class=\"pre\">html_template_path</span></span><a class=\"heading-anchor\" href=\"#django.views.debug.ExceptionReporter.html_template_path\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Property that returns a <a class=\"reference external\" href=\"https://docs.python.org/3/library/pathlib.html#pathlib.Path\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">pathlib.Path</span></code></a> representing the absolute\nfilesystem path to a template for rendering the HTML representation of\nthe exception. Defaults to the Django provided template.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.ExceptionReporter.text_template_path\">\n<span class=\"sig-name descname\"><span class=\"pre\">text_template_path</span></span><a class=\"heading-anchor\" href=\"#django.views.debug.ExceptionReporter.text_template_path\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Property that returns a <a class=\"reference external\" href=\"https://docs.python.org/3/library/pathlib.html#pathlib.Path\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">pathlib.Path</span></code></a> representing the absolute\nfilesystem path to a template for rendering the plain-text\nrepresentation of the exception. Defaults to the Django provided\ntemplate.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.ExceptionReporter.get_traceback_data\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_traceback_data</span></span><span class=\"sig-paren\">(</span><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.views.debug.ExceptionReporter.get_traceback_data\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Return a dictionary containing traceback information.</p>\n<p>This is the main extension point for customizing exception reports, for\nexample:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.views.debug</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">ExceptionReporter</span>\n\n\n<span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">CustomExceptionReporter</span><span class=\"p\">(</span><span class=\"n\">ExceptionReporter</span><span class=\"p\">):</span>\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">get_traceback_data</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"n\">data</span> <span class=\"o\">=</span> <span class=\"nb\">super</span><span class=\"p\">()</span><span class=\"o\">.</span><span class=\"n\">get_traceback_data</span><span class=\"p\">()</span>\n        <span class=\"c1\"># ... remove/add something here ...</span>\n        <span class=\"k\">return</span> <span class=\"n\">data</span>\n</code></pre></div>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.ExceptionReporter.get_traceback_html\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_traceback_html</span></span><span class=\"sig-paren\">(</span><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.views.debug.ExceptionReporter.get_traceback_html\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Return HTML version of exception report.</p>\n<p>Used for HTML version of debug 500 HTTP error page.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.views.debug.ExceptionReporter.get_traceback_text\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_traceback_text</span></span><span class=\"sig-paren\">(</span><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.views.debug.ExceptionReporter.get_traceback_text\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Return plain text version of exception report.</p>\n<p>Used for plain text version of debug 500 HTTP error page and email\nreports.</p>\n</dd></dl>\n\n</dd></dl>\n\n<p>As with the filter class, you may control which exception reporter class to use\nwithin any given view by setting the <code class=\"docutils literal notranslate\"><span class=\"pre\">HttpRequest</span></code>’s\n<code class=\"docutils literal notranslate\"><span class=\"pre\">exception_reporter_class</span></code> attribute:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">my_view</span><span class=\"p\">(</span><span class=\"n\">request</span><span class=\"p\">):</span>\n    <span class=\"k\">if</span> <span class=\"n\">request</span><span class=\"o\">.</span><span class=\"n\">user</span><span class=\"o\">.</span><span class=\"n\">is_authenticated</span><span class=\"p\">:</span>\n        <span class=\"n\">request</span><span class=\"o\">.</span><span class=\"n\">exception_reporter_class</span> <span class=\"o\">=</span> <span class=\"n\">CustomExceptionReporter</span><span class=\"p\">()</span>\n    <span class=\"o\">...</span>\n</code></pre></div>\n<aside class=\"admonition admonition-seealso\">\n<p class=\"admonition-title\">See also</p>\n<p>You can also set up custom error reporting by writing a custom piece of\n<a class=\"reference internal\" href=\"/en/5.2/topics/http/middleware/#exception-middleware\"><span class=\"std std-ref\">exception middleware</span></a>. If you do write custom\nerror handling, it’s a good idea to emulate Django’s built-in error handling\nand only report/log errors if <a class=\"reference internal\" href=\"/en/5.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code>.</p>\n</aside>\n</section>\n</section>","rootId":"how-to-manage-error-reporting","toc":[{"title":"Email reports","anchor":"email-reports","children":[{"title":"Server errors","anchor":"server-errors","children":[]},{"title":"404 errors","anchor":"errors","children":[]}]},{"title":"Filtering error reports","anchor":"filtering-error-reports","children":[{"title":"Filtering sensitive information","anchor":"filtering-sensitive-information","children":[]},{"title":"Custom error reports","anchor":"custom-error-reports","children":[]}]}],"breadcrumbs":[{"docname":"howto/index","title":"How-to guides","url":"/en/5.2/howto/"}],"prev":{"docname":"howto/logging","title":"How to configure and use logging","url":"/en/5.2/howto/logging/"},"next":{"docname":"howto/delete-app","title":"How to delete a Django application","url":"/en/5.2/howto/delete-app/"},"formats":{"html":"/en/5.2/howto/error-reporting/","markdown":"/en/5.2/howto/error-reporting.md","json":"/en/5.2/howto/error-reporting.json"},"source":"https://github.com/django/django/blob/stable/5.2.x/docs/howto/error-reporting.txt","official":"https://docs.djangoproject.com/en/5.2/howto/error-reporting/","inVersions":["dev","6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9","1.8"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}