<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Error reporting — Django 1.4.8 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '1.4.8', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <link rel="top" title="Django 1.4.8 documentation" href="../index.html" /> <link rel="up" title="“How-to” guides" href="index.html" /> <link rel="next" title="Providing initial data for models" href="initial-data.html" /> <link rel="prev" title="How to use Django with Apache and mod_python" href="deployment/modpython.html" /> <script type="text/javascript" src="../templatebuiltins.js"></script> <script type="text/javascript"> (function($) { if (!django_template_builtins) { // templatebuiltins.js missing, do nothing. return; } $(document).ready(function() { // Hyperlink Django template tags and filters var base = "../ref/templates/builtins.html"; if (base == "#") { // Special case for builtins.html itself base = ""; } // Tags are keywords, class '.k' $("div.highlight\\-html\\+django span.k").each(function(i, elem) { var tagname = $(elem).text(); if ($.inArray(tagname, django_template_builtins.ttags) != -1) { var fragment = tagname.replace(/_/, '-'); $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>"); } }); // Filters are functions, class '.nf' $("div.highlight\\-html\\+django span.nf").each(function(i, elem) { var filtername = $(elem).text(); if ($.inArray(filtername, django_template_builtins.tfilters) != -1) { var fragment = filtername.replace(/_/, '-'); $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>"); } }); }); })(jQuery); </script> </head> <body> <div class="document"> <div id="custom-doc" class="yui-t6"> <div id="hd"> <h1><a href="../index.html">Django 1.4.8 documentation</a></h1> <div id="global-nav"> <a title="Home page" href="../index.html">Home</a> | <a title="Table of contents" href="../contents.html">Table of contents</a> | <a title="Global index" href="../genindex.html">Index</a> | <a title="Module index" href="../py-modindex.html">Modules</a> </div> <div class="nav"> « <a href="deployment/modpython.html" title="How to use Django with Apache and mod_python">previous</a> | <a href="index.html" title="&#8220;How-to&#8221; guides" accesskey="U">up</a> | <a href="initial-data.html" title="Providing initial data for models">next</a> »</div> </div> <div id="bd"> <div id="yui-main"> <div class="yui-b"> <div class="yui-g" id="howto-error-reporting"> <div class="section" id="s-error-reporting"> <span id="error-reporting"></span><h1>Error reporting<a class="headerlink" href="#error-reporting" title="Permalink to this headline">¶</a></h1> <p>When you’re running a public site you should always turn off the <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> setting. That will make your server run much faster, and will also prevent malicious users from seeing details of your application that can be revealed by the error pages.</p> <p>However, running with <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> set to <tt class="docutils literal"><span class="pre">False</span></tt> means you’ll never see errors generated by your site – everyone will just see your public error pages. You need to keep track of errors that occur in deployed sites, so Django can be configured to create reports with details about those errors.</p> <div class="section" id="s-email-reports"> <span id="email-reports"></span><h2>Email reports<a class="headerlink" href="#email-reports" title="Permalink to this headline">¶</a></h2> <div class="section" id="s-server-errors"> <span id="server-errors"></span><h3>Server errors<a class="headerlink" href="#server-errors" title="Permalink to this headline">¶</a></h3> <p>When <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> is <tt class="docutils literal"><span class="pre">False</span></tt>, Django will email the users listed in the <a class="reference internal" href="../ref/settings.html#std:setting-ADMINS"><tt class="xref std std-setting docutils literal"><span class="pre">ADMINS</span></tt></a> setting whenever your code raises an unhandled exception and results in an internal server error (HTTP status code 500). This gives the administrators immediate notification of any errors. The <a class="reference internal" href="../ref/settings.html#std:setting-ADMINS"><tt class="xref std std-setting docutils literal"><span class="pre">ADMINS</span></tt></a> will get a description of the error, a complete Python traceback, and details about the HTTP request that caused the error.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">In order to send email, Django requires a few settings telling it how to connect to your mail server. At the very least, you’ll need to specify <a class="reference internal" href="../ref/settings.html#std:setting-EMAIL_HOST"><tt class="xref std std-setting docutils literal"><span class="pre">EMAIL_HOST</span></tt></a> and possibly <a class="reference internal" href="../ref/settings.html#std:setting-EMAIL_HOST_USER"><tt class="xref std std-setting docutils literal"><span class="pre">EMAIL_HOST_USER</span></tt></a> and <a class="reference internal" href="../ref/settings.html#std:setting-EMAIL_HOST_PASSWORD"><tt class="xref std std-setting docutils literal"><span class="pre">EMAIL_HOST_PASSWORD</span></tt></a>, though other settings may be also required depending on your mail server’s configuration. Consult <a class="reference internal" href="../ref/settings.html"><em>the Django settings documentation</em></a> for a full list of email-related settings.</p> </div> <p>By default, Django will send email from <a class="reference external" href="mailto:root%40localhost">root<span>@</span>localhost</a>. However, some mail providers reject all email from this address. To use a different sender address, modify the <a class="reference internal" href="../ref/settings.html#std:setting-SERVER_EMAIL"><tt class="xref std std-setting docutils literal"><span class="pre">SERVER_EMAIL</span></tt></a> setting.</p> <p>To disable this behavior, just remove all entries from the <a class="reference internal" href="../ref/settings.html#std:setting-ADMINS"><tt class="xref std std-setting docutils literal"><span class="pre">ADMINS</span></tt></a> setting.</p> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <div class="versionadded"> <span class="title">New in Django 1.3:</span> <a class="reference internal" href="../releases/1.3.html"><em>Please see the release notes</em></a></div> <p class="last">Server error emails are sent using the logging framework, so you can customize this behavior by <a class="reference internal" href="../topics/logging.html"><em>customizing your logging configuration</em></a>.</p> </div> </div> <div class="section" id="s-errors"> <span id="errors"></span><h3>404 errors<a class="headerlink" href="#errors" title="Permalink to this headline">¶</a></h3> <p>Django can also be configured to email errors about broken links (404 “page not found” errors). Django sends emails about 404 errors when:</p> <ul class="simple"> <li><a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> is <tt class="docutils literal"><span class="pre">False</span></tt></li> <li><a class="reference internal" href="../ref/settings.html#std:setting-SEND_BROKEN_LINK_EMAILS"><tt class="xref std std-setting docutils literal"><span class="pre">SEND_BROKEN_LINK_EMAILS</span></tt></a> is <tt class="docutils literal"><span class="pre">True</span></tt></li> <li>Your <a class="reference internal" href="../ref/settings.html#std:setting-MIDDLEWARE_CLASSES"><tt class="xref std std-setting docutils literal"><span class="pre">MIDDLEWARE_CLASSES</span></tt></a> setting includes <tt class="docutils literal"><span class="pre">CommonMiddleware</span></tt> (which it does by default).</li> </ul> <p>If those conditions are met, Django will email the users listed in the <a class="reference internal" href="../ref/settings.html#std:setting-MANAGERS"><tt class="xref std std-setting docutils literal"><span class="pre">MANAGERS</span></tt></a> setting whenever your code raises a 404 and the request has a referer. (It doesn’t bother to email for 404s that don’t have a referer – those are usually just people typing in broken URLs or broken Web ‘bots).</p> <p>You can tell Django to stop reporting particular 404s by tweaking the <a class="reference internal" href="../ref/settings.html#std:setting-IGNORABLE_404_URLS"><tt class="xref std std-setting docutils literal"><span class="pre">IGNORABLE_404_URLS</span></tt></a> setting. It should be a tuple of compiled regular expression objects. For example:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">re</span> <span class="n">IGNORABLE_404_URLS</span> <span class="o">=</span> <span class="p">(</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s">r'\.(php|cgi)$'</span><span class="p">),</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s">r'^/phpmyadmin/'</span><span class="p">),</span> <span class="p">)</span> </pre></div> </div> <p>In this example, a 404 to any URL ending with <tt class="docutils literal"><span class="pre">.php</span></tt> or <tt class="docutils literal"><span class="pre">.cgi</span></tt> will <em>not</em> be reported. Neither will any URL starting with <tt class="docutils literal"><span class="pre">/phpmyadmin/</span></tt>.</p> <p>The following example shows how to exclude some conventional URLs that browsers and crawlers often request:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">re</span> <span class="n">IGNORABLE_404_URLS</span> <span class="o">=</span> <span class="p">(</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s">r'^/apple-touch-icon.*\.png$'</span><span class="p">),</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s">r'^/favicon\.ico$'</span><span class="p">),</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s">r'^/robots\.txt$'</span><span class="p">),</span> <span class="p">)</span> </pre></div> </div> <p>(Note that these are regular expressions, so we put a backslash in front of periods to escape them.)</p> <p>The best way to disable this behavior is to set <a class="reference internal" href="../ref/settings.html#std:setting-SEND_BROKEN_LINK_EMAILS"><tt class="xref std std-setting docutils literal"><span class="pre">SEND_BROKEN_LINK_EMAILS</span></tt></a> to <tt class="docutils literal"><span class="pre">False</span></tt>.</p> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <div class="versionadded"> <span class="title">New in Django 1.3:</span> <a class="reference internal" href="../releases/1.3.html"><em>Please see the release notes</em></a></div> <p class="last">404 errors are logged using the logging framework. By default, these log records are ignored, but you can use them for error reporting by writing a handler and <a class="reference internal" href="../topics/logging.html"><em>configuring logging</em></a> appropriately.</p> </div> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <div class="versionchanged"> <span class="title">Changed in Django 1.4:</span> <a class="reference internal" href="../releases/1.4.html"><em>Please see the release notes</em></a></div> <p class="last">Previously, two settings were used to control which URLs not to report: <a class="reference internal" href="../ref/settings.html#std:setting-IGNORABLE_404_STARTS"><tt class="xref std std-setting docutils literal"><span class="pre">IGNORABLE_404_STARTS</span></tt></a> and <a class="reference internal" href="../ref/settings.html#std:setting-IGNORABLE_404_ENDS"><tt class="xref std std-setting docutils literal"><span class="pre">IGNORABLE_404_ENDS</span></tt></a>. They were replaced by <a class="reference internal" href="../ref/settings.html#std:setting-IGNORABLE_404_URLS"><tt class="xref std std-setting docutils literal"><span class="pre">IGNORABLE_404_URLS</span></tt></a>.</p> </div> </div> </div> <div class="section" id="s-filtering-error-reports"> <span id="s-id1"></span><span id="filtering-error-reports"></span><span id="id1"></span><h2>Filtering error reports<a class="headerlink" href="#filtering-error-reports" title="Permalink to this headline">¶</a></h2> <div class="versionadded"> <span class="title">New in Django 1.4:</span> <a class="reference internal" href="../releases/1.4.html"><em>Please see the release notes</em></a></div> <div class="section" id="s-filtering-sensitive-information"> <span id="filtering-sensitive-information"></span><h3>Filtering sensitive information<a class="headerlink" href="#filtering-sensitive-information" title="Permalink to this headline">¶</a></h3> <p>Error reports are really helpful for debugging errors, so it is generally useful to record as much relevant information about those errors as possible. For example, by default Django records the <a class="reference external" href="http://en.wikipedia.org/wiki/Stack_trace">full traceback</a> for the exception raised, each <a class="reference external" href="http://en.wikipedia.org/wiki/Stack_frame">traceback frame</a>‘s local variables, and the <tt class="xref py py-class docutils literal"><span class="pre">HttpRequest</span></tt>‘s <a class="reference internal" href="../ref/request-response.html#httprequest-attributes"><em>attributes</em></a>.</p> <p>However, sometimes certain types of information may be too sensitive and thus may not be appropriate to be kept track of, for example a user’s password or credit card number. So Django offers a set of function decorators to help you control which information should be filtered out of error reports in a production environment (that is, where <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> is set to <tt class="docutils literal"><span class="pre">False</span></tt>): <a class="reference internal" href="#sensitive_variables" title="sensitive_variables"><tt class="xref py py-func docutils literal"><span class="pre">sensitive_variables()</span></tt></a> and <a class="reference internal" href="#sensitive_post_parameters" title="sensitive_post_parameters"><tt class="xref py py-func docutils literal"><span class="pre">sensitive_post_parameters()</span></tt></a>.</p> <dl class="function"> <dt id="sensitive_variables"> <tt class="descname">sensitive_variables</tt>(<em>*variables</em>)<a class="headerlink" href="#sensitive_variables" title="Permalink to this definition">¶</a></dt> <dd><p>If a function (either a view or any regular callback) in your code uses local variables susceptible to contain sensitive information, you may prevent the values of those variables from being included in error reports using the <tt class="docutils literal"><span class="pre">sensitive_variables</span></tt> decorator:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.views.decorators.debug</span> <span class="kn">import</span> <span class="n">sensitive_variables</span> <span class="nd">@sensitive_variables</span><span class="p">(</span><span class="s">'user'</span><span class="p">,</span> <span class="s">'pw'</span><span class="p">,</span> <span class="s">'cc'</span><span class="p">)</span> <span class="k">def</span> <span class="nf">process_info</span><span class="p">(</span><span class="n">user</span><span class="p">):</span> <span class="n">pw</span> <span class="o">=</span> <span class="n">user</span><span class="o">.</span><span class="n">pass_word</span> <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> <span class="n">name</span> <span class="o">=</span> <span class="n">user</span><span class="o">.</span><span class="n">name</span> <span class="o">...</span> </pre></div> </div> <p>In the above example, the values for the <tt class="docutils literal"><span class="pre">user</span></tt>, <tt class="docutils literal"><span class="pre">pw</span></tt> and <tt class="docutils literal"><span class="pre">cc</span></tt> variables will be hidden and replaced with stars (<cite>**********</cite>) in the error reports, whereas the value of the <tt class="docutils literal"><span class="pre">name</span></tt> variable will be disclosed.</p> <p>To systematically hide all local variables of a function from error logs, do not provide any argument to the <tt class="docutils literal"><span class="pre">sensitive_variables</span></tt> decorator:</p> <div class="highlight-python"><div class="highlight"><pre><span class="nd">@sensitive_variables</span><span class="p">()</span> <span class="k">def</span> <span class="nf">my_function</span><span class="p">():</span> <span class="o">...</span> </pre></div> </div> </dd></dl> <dl class="function"> <dt id="sensitive_post_parameters"> <tt class="descname">sensitive_post_parameters</tt>(<em>*parameters</em>)<a class="headerlink" href="#sensitive_post_parameters" title="Permalink to this definition">¶</a></dt> <dd><p>If one of your views receives an <tt class="xref py py-class docutils literal"><span class="pre">HttpRequest</span></tt> object with <tt class="xref py py-attr docutils literal"><span class="pre">POST</span> <span class="pre">parameters</span></tt> susceptible to contain sensitive information, you may prevent the values of those parameters from being included in the error reports using the <tt class="docutils literal"><span class="pre">sensitive_post_parameters</span></tt> decorator:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.views.decorators.debug</span> <span class="kn">import</span> <span class="n">sensitive_post_parameters</span> <span class="nd">@sensitive_post_parameters</span><span class="p">(</span><span class="s">'pass_word'</span><span class="p">,</span> <span class="s">'credit_card_number'</span><span class="p">)</span> <span class="k">def</span> <span class="nf">record_user_profile</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> <span class="n">UserProfile</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><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> <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="s">'pass_word'</span><span class="p">],</span> <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="s">'credit_card_number'</span><span class="p">],</span> <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="s">'name'</span><span class="p">])</span> <span class="o">...</span> </pre></div> </div> <p>In the above example, the values for the <tt class="docutils literal"><span class="pre">pass_word</span></tt> and <tt class="docutils literal"><span class="pre">credit_card_number</span></tt> POST parameters will be hidden and replaced with stars (<cite>**********</cite>) in the request’s representation inside the error reports, whereas the value of the <tt class="docutils literal"><span class="pre">name</span></tt> parameter will be disclosed.</p> <p>To systematically hide all POST parameters of a request in error reports, do not provide any argument to the <tt class="docutils literal"><span class="pre">sensitive_post_parameters</span></tt> decorator:</p> <div class="highlight-python"><div class="highlight"><pre><span class="nd">@sensitive_post_parameters</span><span class="p">()</span> <span class="k">def</span> <span class="nf">my_view</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> <span class="o">...</span> </pre></div> </div> </dd></dl> <div class="admonition note"> <p class="first admonition-title">Note</p> <div class="versionchanged"> <span class="title">Changed in Django 1.4:</span> <a class="reference internal" href="../releases/1.4.html"><em>Please see the release notes</em></a></div> <p class="last">Since version 1.4, all POST parameters are systematically filtered out of error reports for certain <tt class="xref py py-mod docutils literal"><span class="pre">contrib.views.auth</span></tt> views (<tt class="docutils literal"><span class="pre">login</span></tt>, <tt class="docutils literal"><span class="pre">password_reset_confirm</span></tt>, <tt class="docutils literal"><span class="pre">password_change</span></tt>, and <tt class="docutils literal"><span class="pre">add_view</span></tt> and <tt class="docutils literal"><span class="pre">user_change_password</span></tt> in the <tt class="docutils literal"><span class="pre">auth</span></tt> admin) to prevent the leaking of sensitive information such as user passwords.</p> </div> </div> <div class="section" id="s-custom-error-reports"> <span id="s-id2"></span><span id="custom-error-reports"></span><span id="id2"></span><h3>Custom error reports<a class="headerlink" href="#custom-error-reports" title="Permalink to this headline">¶</a></h3> <p>All <a class="reference internal" href="#sensitive_variables" title="sensitive_variables"><tt class="xref py py-func docutils literal"><span class="pre">sensitive_variables()</span></tt></a> and <a class="reference internal" href="#sensitive_post_parameters" title="sensitive_post_parameters"><tt class="xref py py-func docutils literal"><span class="pre">sensitive_post_parameters()</span></tt></a> do is, respectively, annotate the decorated function with the names of sensitive variables and annotate the <tt class="docutils literal"><span class="pre">HttpRequest</span></tt> object with the names of sensitive POST parameters, so that this sensitive information can later be filtered out of reports when an error occurs. The actual filtering is done by Django’s default error reporter filter: <a class="reference internal" href="#django.views.debug.SafeExceptionReporterFilter" title="django.views.debug.SafeExceptionReporterFilter"><tt class="xref py py-class docutils literal"><span class="pre">django.views.debug.SafeExceptionReporterFilter</span></tt></a>. This filter uses the decorators’ annotations to replace the corresponding values with stars (<cite>**********</cite>) when the error reports are produced. If you wish to override or customize this default behavior for your entire site, you need to define your own filter class and tell Django to use it via the <a class="reference internal" href="../ref/settings.html#std:setting-DEFAULT_EXCEPTION_REPORTER_FILTER"><tt class="xref std std-setting docutils literal"><span class="pre">DEFAULT_EXCEPTION_REPORTER_FILTER</span></tt></a> setting:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">DEFAULT_EXCEPTION_REPORTER_FILTER</span> <span class="o">=</span> <span class="s">'path.to.your.CustomExceptionReporterFilter'</span> </pre></div> </div> <p>You may also control in a more granular way which filter to use within any given view by setting the <tt class="docutils literal"><span class="pre">HttpRequest</span></tt>‘s <tt class="docutils literal"><span class="pre">exception_reporter_filter</span></tt> attribute:</p> <div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">my_view</span><span class="p">(</span><span class="n">request</span><span class="p">):</span> <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> <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> <span class="o">...</span> </pre></div> </div> <p>Your custom filter class needs to inherit from <a class="reference internal" href="#django.views.debug.SafeExceptionReporterFilter" title="django.views.debug.SafeExceptionReporterFilter"><tt class="xref py py-class docutils literal"><span class="pre">django.views.debug.SafeExceptionReporterFilter</span></tt></a> and may override the following methods:</p> <dl class="class"> <dt id="django.views.debug.SafeExceptionReporterFilter"> <em class="property">class </em><tt class="descclassname">django.views.debug.</tt><tt class="descname">SafeExceptionReporterFilter</tt><a class="headerlink" href="#django.views.debug.SafeExceptionReporterFilter" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="SafeExceptionReporterFilter.is_active"> <tt class="descclassname">SafeExceptionReporterFilter.</tt><tt class="descname">is_active</tt>(<em>self</em>, <em>request</em>)<a class="headerlink" href="#SafeExceptionReporterFilter.is_active" title="Permalink to this definition">¶</a></dt> <dd><p>Returns <tt class="docutils literal"><span class="pre">True</span></tt> to activate the filtering operated in the other methods. By default the filter is active if <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> is <tt class="docutils literal"><span class="pre">False</span></tt>.</p> </dd></dl> <dl class="method"> <dt id="SafeExceptionReporterFilter.get_request_repr"> <tt class="descclassname">SafeExceptionReporterFilter.</tt><tt class="descname">get_request_repr</tt>(<em>self</em>, <em>request</em>)<a class="headerlink" href="#SafeExceptionReporterFilter.get_request_repr" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the representation string of the request object, that is, the value that would be returned by <tt class="docutils literal"><span class="pre">repr(request)</span></tt>, except it uses the filtered dictionary of POST parameters as determined by <a class="reference internal" href="#SafeExceptionReporterFilter.get_post_parameters" title="SafeExceptionReporterFilter.get_post_parameters"><tt class="xref py py-meth docutils literal"><span class="pre">SafeExceptionReporterFilter.get_post_parameters()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="SafeExceptionReporterFilter.get_post_parameters"> <tt class="descclassname">SafeExceptionReporterFilter.</tt><tt class="descname">get_post_parameters</tt>(<em>self</em>, <em>request</em>)<a class="headerlink" href="#SafeExceptionReporterFilter.get_post_parameters" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the filtered dictionary of POST parameters. By default it replaces the values of sensitive parameters with stars (<cite>**********</cite>).</p> </dd></dl> <dl class="method"> <dt id="SafeExceptionReporterFilter.get_traceback_frame_variables"> <tt class="descclassname">SafeExceptionReporterFilter.</tt><tt class="descname">get_traceback_frame_variables</tt>(<em>self</em>, <em>request</em>, <em>tb_frame</em>)<a class="headerlink" href="#SafeExceptionReporterFilter.get_traceback_frame_variables" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the filtered dictionary of local variables for the given traceback frame. By default it replaces the values of sensitive variables with stars (<cite>**********</cite>).</p> </dd></dl> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <p class="last">You can also set up custom error reporting by writing a custom piece of <a class="reference internal" href="../topics/http/middleware.html#exception-middleware"><em>exception middleware</em></a>. If you do write custom error handling, it’s a good idea to emulate Django’s built-in error handling and only report/log errors if <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> is <tt class="docutils literal"><span class="pre">False</span></tt>.</p> </div> </div> </div> </div> </div> </div> </div> <div class="yui-b" id="sidebar"> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Error reporting</a><ul> <li><a class="reference internal" href="#email-reports">Email reports</a><ul> <li><a class="reference internal" href="#server-errors">Server errors</a></li> <li><a class="reference internal" href="#errors">404 errors</a></li> </ul> </li> <li><a class="reference internal" href="#filtering-error-reports">Filtering error reports</a><ul> <li><a class="reference internal" href="#filtering-sensitive-information">Filtering sensitive information</a></li> <li><a class="reference internal" href="#custom-error-reports">Custom error reports</a></li> </ul> </li> </ul> </li> </ul> <h3>Browse</h3> <ul> <li>Prev: <a href="deployment/modpython.html">How to use Django with Apache and mod_python</a></li> <li>Next: <a href="initial-data.html">Providing initial data for models</a></li> </ul> <h3>You are here:</h3> <ul> <li> <a href="../index.html">Django 1.4.8 documentation</a> <ul><li><a href="index.html">“How-to” guides</a> <ul><li>Error reporting</li></ul> </li></ul> </li> </ul> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/howto/error-reporting.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <h3>Last update:</h3> <p class="topless">Oct 30, 2013</p> </div> </div> <div id="ft"> <div class="nav"> « <a href="deployment/modpython.html" title="How to use Django with Apache and mod_python">previous</a> | <a href="index.html" title="&#8220;How-to&#8221; guides" accesskey="U">up</a> | <a href="initial-data.html" title="Providing initial data for models">next</a> »</div> </div> </div> <div class="clearer"></div> </div> </body> </html>