<!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" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>django.views.debug &#8212; Django 2.0.dev20170216164632 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:     '2.0.dev20170216164632',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </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="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.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 role="document">

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../../index.html">Django 2.0.dev20170216164632 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="../../index.html" title="Module code" accesskey="U">up</a></div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="_modules-django-views-debug">
            
  <h1>Source code for django.views.debug</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">functools</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">types</span>

<span class="kn">from</span> <span class="nn">django.conf</span> <span class="k">import</span> <span class="n">settings</span>
<span class="kn">from</span> <span class="nn">django.http</span> <span class="k">import</span> <span class="n">HttpResponse</span><span class="p">,</span> <span class="n">HttpResponseNotFound</span>
<span class="kn">from</span> <span class="nn">django.template</span> <span class="k">import</span> <span class="n">Context</span><span class="p">,</span> <span class="n">Engine</span><span class="p">,</span> <span class="n">TemplateDoesNotExist</span>
<span class="kn">from</span> <span class="nn">django.template.defaultfilters</span> <span class="k">import</span> <span class="n">force_escape</span><span class="p">,</span> <span class="n">pprint</span>
<span class="kn">from</span> <span class="nn">django.urls</span> <span class="k">import</span> <span class="n">Resolver404</span><span class="p">,</span> <span class="n">resolve</span>
<span class="kn">from</span> <span class="nn">django.utils</span> <span class="k">import</span> <span class="n">timezone</span>
<span class="kn">from</span> <span class="nn">django.utils.datastructures</span> <span class="k">import</span> <span class="n">MultiValueDict</span>
<span class="kn">from</span> <span class="nn">django.utils.encoding</span> <span class="k">import</span> <span class="n">force_text</span>
<span class="kn">from</span> <span class="nn">django.utils.module_loading</span> <span class="k">import</span> <span class="n">import_string</span>
<span class="kn">from</span> <span class="nn">django.utils.translation</span> <span class="k">import</span> <span class="n">gettext</span> <span class="k">as</span> <span class="n">_</span>

<span class="c1"># Minimal Django templates engine to render the error templates</span>
<span class="c1"># regardless of the project&#39;s TEMPLATES setting.</span>
<span class="n">DEBUG_ENGINE</span> <span class="o">=</span> <span class="n">Engine</span><span class="p">(</span><span class="n">debug</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<span class="n">HIDDEN_SETTINGS</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s1">&#39;API|TOKEN|KEY|SECRET|PASS|SIGNATURE&#39;</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>

<span class="n">CLEANSED_SUBSTITUTE</span> <span class="o">=</span> <span class="s1">&#39;********************&#39;</span>


<span class="k">class</span> <span class="nc">CallableSettingWrapper</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot; Object to wrap callable appearing in settings</span>

<span class="sd">    * Not to call in the debug page (#21345).</span>
<span class="sd">    * Not to break the debug page if the callable forbidding to set attributes (#23070).</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">callable_setting</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_wrapped</span> <span class="o">=</span> <span class="n">callable_setting</span>

    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_wrapped</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">cleanse_setting</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Cleanse an individual setting key/value of sensitive content.</span>

<span class="sd">    If the value is a dictionary, recursively cleanse the keys in</span>
<span class="sd">    that dictionary.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">HIDDEN_SETTINGS</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">key</span><span class="p">):</span>
            <span class="n">cleansed</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
                <span class="n">cleansed</span> <span class="o">=</span> <span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">cleanse_setting</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">cleansed</span> <span class="o">=</span> <span class="n">value</span>
    <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
        <span class="c1"># If the key isn&#39;t regex-able, just return as-is.</span>
        <span class="n">cleansed</span> <span class="o">=</span> <span class="n">value</span>

    <span class="k">if</span> <span class="n">callable</span><span class="p">(</span><span class="n">cleansed</span><span class="p">):</span>
        <span class="c1"># For fixing #21345 and #23070</span>
        <span class="n">cleansed</span> <span class="o">=</span> <span class="n">CallableSettingWrapper</span><span class="p">(</span><span class="n">cleansed</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">cleansed</span>


<span class="k">def</span> <span class="nf">get_safe_settings</span><span class="p">():</span>
    <span class="s2">&quot;Returns a dictionary of the settings module, with sensitive settings blurred out.&quot;</span>
    <span class="n">settings_dict</span> <span class="o">=</span> <span class="p">{}</span>
    <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">dir</span><span class="p">(</span><span class="n">settings</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">k</span><span class="o">.</span><span class="n">isupper</span><span class="p">():</span>
            <span class="n">settings_dict</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">cleanse_setting</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">settings</span><span class="p">,</span> <span class="n">k</span><span class="p">))</span>
    <span class="k">return</span> <span class="n">settings_dict</span>


<span class="k">def</span> <span class="nf">technical_500_response</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tb</span><span class="p">,</span> <span class="n">status_code</span><span class="o">=</span><span class="mi">500</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Create a technical server error response. The last three arguments are</span>
<span class="sd">    the values returned from sys.exc_info() and friends.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">reporter</span> <span class="o">=</span> <span class="n">ExceptionReporter</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tb</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">request</span><span class="o">.</span><span class="n">is_ajax</span><span class="p">():</span>
        <span class="n">text</span> <span class="o">=</span> <span class="n">reporter</span><span class="o">.</span><span class="n">get_traceback_text</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">status</span><span class="o">=</span><span class="n">status_code</span><span class="p">,</span> <span class="n">content_type</span><span class="o">=</span><span class="s1">&#39;text/plain&#39;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">html</span> <span class="o">=</span> <span class="n">reporter</span><span class="o">.</span><span class="n">get_traceback_html</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="n">html</span><span class="p">,</span> <span class="n">status</span><span class="o">=</span><span class="n">status_code</span><span class="p">,</span> <span class="n">content_type</span><span class="o">=</span><span class="s1">&#39;text/html&#39;</span><span class="p">)</span>


<span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">get_default_exception_reporter_filter</span><span class="p">():</span>
    <span class="c1"># Instantiate the default filter for the first time and cache it.</span>
    <span class="k">return</span> <span class="n">import_string</span><span class="p">(</span><span class="n">settings</span><span class="o">.</span><span class="n">DEFAULT_EXCEPTION_REPORTER_FILTER</span><span class="p">)()</span>


<span class="k">def</span> <span class="nf">get_exception_reporter_filter</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
    <span class="n">default_filter</span> <span class="o">=</span> <span class="n">get_default_exception_reporter_filter</span><span class="p">()</span>
    <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="s1">&#39;exception_reporter_filter&#39;</span><span class="p">,</span> <span class="n">default_filter</span><span class="p">)</span>


<span class="k">class</span> <span class="nc">ExceptionReporterFilter</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Base for all exception reporter filter classes. All overridable hooks</span>
<span class="sd">    contain lenient default behaviors.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">get_post_parameters</span><span class="p">(</span><span class="bp">self</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="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">{}</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">request</span><span class="o">.</span><span class="n">POST</span>

    <span class="k">def</span> <span class="nf">get_traceback_frame_variables</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">tb_frame</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="o">.</span><span class="n">items</span><span class="p">())</span>


<div class="viewcode-block" id="SafeExceptionReporterFilter"><a class="viewcode-back" href="../../../howto/error-reporting.html#django.views.debug.SafeExceptionReporterFilter">[docs]</a><span class="k">class</span> <span class="nc">SafeExceptionReporterFilter</span><span class="p">(</span><span class="n">ExceptionReporterFilter</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Use annotations made by the sensitive_post_parameters and</span>
<span class="sd">    sensitive_variables decorators to filter out sensitive information.</span>
<span class="sd">    &quot;&quot;&quot;</span>

<div class="viewcode-block" id="SafeExceptionReporterFilter.is_active"><a class="viewcode-back" href="../../../howto/error-reporting.html#django.views.debug.SafeExceptionReporterFilter.is_active">[docs]</a>    <span class="k">def</span> <span class="nf">is_active</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        This filter is to add safety in production environments (i.e. DEBUG</span>
<span class="sd">        is False). If DEBUG is True then your site is not safe anyway.</span>
<span class="sd">        This hook is provided as a convenience to easily activate or</span>
<span class="sd">        deactivate the filter on a per request basis.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">settings</span><span class="o">.</span><span class="n">DEBUG</span> <span class="ow">is</span> <span class="kc">False</span></div>

    <span class="k">def</span> <span class="nf">get_cleansed_multivaluedict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">multivaluedict</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Replaces the keys in a MultiValueDict marked as sensitive with stars.</span>
<span class="sd">        This mitigates leaking sensitive POST parameters if something like</span>
<span class="sd">        request.POST[&#39;nonexistent_key&#39;] throws an exception (#21098).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">sensitive_post_parameters</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="s1">&#39;sensitive_post_parameters&#39;</span><span class="p">,</span> <span class="p">[])</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_active</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="ow">and</span> <span class="n">sensitive_post_parameters</span><span class="p">:</span>
            <span class="n">multivaluedict</span> <span class="o">=</span> <span class="n">multivaluedict</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
            <span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">sensitive_post_parameters</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">multivaluedict</span><span class="p">:</span>
                    <span class="n">multivaluedict</span><span class="p">[</span><span class="n">param</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
        <span class="k">return</span> <span class="n">multivaluedict</span>

<div class="viewcode-block" id="SafeExceptionReporterFilter.get_post_parameters"><a class="viewcode-back" href="../../../howto/error-reporting.html#django.views.debug.SafeExceptionReporterFilter.get_post_parameters">[docs]</a>    <span class="k">def</span> <span class="nf">get_post_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Replaces the values of POST parameters marked as sensitive with</span>
<span class="sd">        stars (*********).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">request</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">{}</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">sensitive_post_parameters</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="s1">&#39;sensitive_post_parameters&#39;</span><span class="p">,</span> <span class="p">[])</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_active</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="ow">and</span> <span class="n">sensitive_post_parameters</span><span class="p">:</span>
                <span class="n">cleansed</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">POST</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
                <span class="k">if</span> <span class="n">sensitive_post_parameters</span> <span class="o">==</span> <span class="s1">&#39;__ALL__&#39;</span><span class="p">:</span>
                    <span class="c1"># Cleanse all parameters.</span>
                    <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">cleansed</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                        <span class="n">cleansed</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
                    <span class="k">return</span> <span class="n">cleansed</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="c1"># Cleanse only the specified parameters.</span>
                    <span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">sensitive_post_parameters</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">cleansed</span><span class="p">:</span>
                            <span class="n">cleansed</span><span class="p">[</span><span class="n">param</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
                    <span class="k">return</span> <span class="n">cleansed</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">request</span><span class="o">.</span><span class="n">POST</span></div>

    <span class="k">def</span> <span class="nf">cleanse_special_types</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="c1"># If value is lazy or a complex object of another kind, this check</span>
            <span class="c1"># might raise an exception. isinstance checks that lazy</span>
            <span class="c1"># MultiValueDicts will have a return value.</span>
            <span class="n">is_multivalue_dict</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">MultiValueDict</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{!r}</span><span class="s1"> while evaluating </span><span class="si">{!r}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">is_multivalue_dict</span><span class="p">:</span>
            <span class="c1"># Cleanse MultiValueDicts (request.POST is the one we usually care about)</span>
            <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_cleansed_multivaluedict</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">value</span>

<div class="viewcode-block" id="SafeExceptionReporterFilter.get_traceback_frame_variables"><a class="viewcode-back" href="../../../howto/error-reporting.html#django.views.debug.SafeExceptionReporterFilter.get_traceback_frame_variables">[docs]</a>    <span class="k">def</span> <span class="nf">get_traceback_frame_variables</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">tb_frame</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Replaces the values of variables marked as sensitive with</span>
<span class="sd">        stars (*********).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Loop through the frame&#39;s callers to see if the sensitive_variables</span>
        <span class="c1"># decorator was used.</span>
        <span class="n">current_frame</span> <span class="o">=</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_back</span>
        <span class="n">sensitive_variables</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">while</span> <span class="n">current_frame</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">current_frame</span><span class="o">.</span><span class="n">f_code</span><span class="o">.</span><span class="n">co_name</span> <span class="o">==</span> <span class="s1">&#39;sensitive_variables_wrapper&#39;</span> <span class="ow">and</span>
                    <span class="s1">&#39;sensitive_variables_wrapper&#39;</span> <span class="ow">in</span> <span class="n">current_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="p">):</span>
                <span class="c1"># The sensitive_variables decorator was used, so we take note</span>
                <span class="c1"># of the sensitive variables&#39; names.</span>
                <span class="n">wrapper</span> <span class="o">=</span> <span class="n">current_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="p">[</span><span class="s1">&#39;sensitive_variables_wrapper&#39;</span><span class="p">]</span>
                <span class="n">sensitive_variables</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">wrapper</span><span class="p">,</span> <span class="s1">&#39;sensitive_variables&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
                <span class="k">break</span>
            <span class="n">current_frame</span> <span class="o">=</span> <span class="n">current_frame</span><span class="o">.</span><span class="n">f_back</span>

        <span class="n">cleansed</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_active</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="ow">and</span> <span class="n">sensitive_variables</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">sensitive_variables</span> <span class="o">==</span> <span class="s1">&#39;__ALL__&#39;</span><span class="p">:</span>
                <span class="c1"># Cleanse all variables</span>
                <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                    <span class="n">cleansed</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="c1"># Cleanse specified variables</span>
                <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                    <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">sensitive_variables</span><span class="p">:</span>
                        <span class="n">value</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cleanse_special_types</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
                    <span class="n">cleansed</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Potentially cleanse the request and any MultiValueDicts if they</span>
            <span class="c1"># are one of the frame variables.</span>
            <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="n">cleansed</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cleanse_special_types</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>

        <span class="k">if</span> <span class="p">(</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_code</span><span class="o">.</span><span class="n">co_name</span> <span class="o">==</span> <span class="s1">&#39;sensitive_variables_wrapper&#39;</span> <span class="ow">and</span>
                <span class="s1">&#39;sensitive_variables_wrapper&#39;</span> <span class="ow">in</span> <span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="p">):</span>
            <span class="c1"># For good measure, obfuscate the decorated function&#39;s arguments in</span>
            <span class="c1"># the sensitive_variables decorator&#39;s frame, in case the variables</span>
            <span class="c1"># associated with those arguments were meant to be obfuscated from</span>
            <span class="c1"># the decorated function&#39;s frame.</span>
            <span class="n">cleansed</span><span class="p">[</span><span class="s1">&#39;func_args&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>
            <span class="n">cleansed</span><span class="p">[</span><span class="s1">&#39;func_kwargs&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">CLEANSED_SUBSTITUTE</span>

        <span class="k">return</span> <span class="n">cleansed</span><span class="o">.</span><span class="n">items</span><span class="p">()</span></div></div>


<span class="k">class</span> <span class="nc">ExceptionReporter</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    A class to organize and coordinate reporting on exceptions.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tb</span><span class="p">,</span> <span class="n">is_email</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">request</span> <span class="o">=</span> <span class="n">request</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filter</span> <span class="o">=</span> <span class="n">get_exception_reporter_filter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span> <span class="o">=</span> <span class="n">exc_type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span> <span class="o">=</span> <span class="n">exc_value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">tb</span> <span class="o">=</span> <span class="n">tb</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">is_email</span> <span class="o">=</span> <span class="n">is_email</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">template_info</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">,</span> <span class="s1">&#39;template_debug&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">template_does_not_exist</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">postmortem</span> <span class="o">=</span> <span class="kc">None</span>

    <span class="k">def</span> <span class="nf">get_traceback_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Return a dictionary containing traceback information.&quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span> <span class="ow">and</span> <span class="nb">issubclass</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="p">,</span> <span class="n">TemplateDoesNotExist</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">template_does_not_exist</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">postmortem</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="o">.</span><span class="n">chain</span> <span class="ow">or</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">]</span>

        <span class="n">frames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_traceback_frames</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">frame</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">frames</span><span class="p">):</span>
            <span class="k">if</span> <span class="s1">&#39;vars&#39;</span> <span class="ow">in</span> <span class="n">frame</span><span class="p">:</span>
                <span class="n">frame_vars</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">frame</span><span class="p">[</span><span class="s1">&#39;vars&#39;</span><span class="p">]:</span>
                    <span class="n">v</span> <span class="o">=</span> <span class="n">pprint</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
                    <span class="c1"># Trim large blobs of data</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">4096</span><span class="p">:</span>
                        <span class="n">v</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">... &lt;trimmed </span><span class="si">%d</span><span class="s1"> bytes string&gt;&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">4096</span><span class="p">],</span> <span class="nb">len</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
                    <span class="n">frame_vars</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">k</span><span class="p">,</span> <span class="n">force_escape</span><span class="p">(</span><span class="n">v</span><span class="p">)))</span>
                <span class="n">frame</span><span class="p">[</span><span class="s1">&#39;vars&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">frame_vars</span>
            <span class="n">frames</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">frame</span>

        <span class="n">unicode_hint</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span> <span class="ow">and</span> <span class="nb">issubclass</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="p">,</span> <span class="ne">UnicodeError</span><span class="p">):</span>
            <span class="n">start</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">,</span> <span class="s1">&#39;start&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="n">end</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">,</span> <span class="s1">&#39;end&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">start</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">end</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">unicode_str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="n">unicode_hint</span> <span class="o">=</span> <span class="n">force_text</span><span class="p">(</span>
                    <span class="n">unicode_str</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="n">start</span> <span class="o">-</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span><span class="nb">min</span><span class="p">(</span><span class="n">end</span> <span class="o">+</span> <span class="mi">5</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">unicode_str</span><span class="p">))],</span>
                    <span class="s1">&#39;ascii&#39;</span><span class="p">,</span> <span class="n">errors</span><span class="o">=</span><span class="s1">&#39;replace&#39;</span>
                <span class="p">)</span>
        <span class="kn">from</span> <span class="nn">django</span> <span class="k">import</span> <span class="n">get_version</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">user_str</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">user_str</span> <span class="o">=</span> <span class="n">force_text</span><span class="p">(</span><span class="bp">self</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="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
                <span class="c1"># request.user may raise OperationalError if the database is</span>
                <span class="c1"># unavailable, for example.</span>
                <span class="n">user_str</span> <span class="o">=</span> <span class="s1">&#39;[unable to retrieve the current user]&#39;</span>

        <span class="n">c</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;is_email&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_email</span><span class="p">,</span>
            <span class="s1">&#39;unicode_hint&#39;</span><span class="p">:</span> <span class="n">unicode_hint</span><span class="p">,</span>
            <span class="s1">&#39;frames&#39;</span><span class="p">:</span> <span class="n">frames</span><span class="p">,</span>
            <span class="s1">&#39;request&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">,</span>
            <span class="s1">&#39;user_str&#39;</span><span class="p">:</span> <span class="n">user_str</span><span class="p">,</span>
            <span class="s1">&#39;filtered_POST_items&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">filter</span><span class="o">.</span><span class="n">get_post_parameters</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span>
            <span class="s1">&#39;settings&#39;</span><span class="p">:</span> <span class="n">get_safe_settings</span><span class="p">(),</span>
            <span class="s1">&#39;sys_executable&#39;</span><span class="p">:</span> <span class="n">sys</span><span class="o">.</span><span class="n">executable</span><span class="p">,</span>
            <span class="s1">&#39;sys_version_info&#39;</span><span class="p">:</span> <span class="s1">&#39;</span><span class="si">%d</span><span class="s1">.</span><span class="si">%d</span><span class="s1">.</span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">3</span><span class="p">],</span>
            <span class="s1">&#39;server_time&#39;</span><span class="p">:</span> <span class="n">timezone</span><span class="o">.</span><span class="n">now</span><span class="p">(),</span>
            <span class="s1">&#39;django_version_info&#39;</span><span class="p">:</span> <span class="n">get_version</span><span class="p">(),</span>
            <span class="s1">&#39;sys_path&#39;</span><span class="p">:</span> <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="p">,</span>
            <span class="s1">&#39;template_info&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">template_info</span><span class="p">,</span>
            <span class="s1">&#39;template_does_not_exist&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">template_does_not_exist</span><span class="p">,</span>
            <span class="s1">&#39;postmortem&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">postmortem</span><span class="p">,</span>
        <span class="p">}</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">c</span><span class="p">[</span><span class="s1">&#39;request_GET_items&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">GET</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
            <span class="n">c</span><span class="p">[</span><span class="s1">&#39;request_FILES_items&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">FILES</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
            <span class="n">c</span><span class="p">[</span><span class="s1">&#39;request_COOKIES_items&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">COOKIES</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
        <span class="c1"># Check whether exception info is available</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="p">:</span>
            <span class="n">c</span><span class="p">[</span><span class="s1">&#39;exception_type&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_type</span><span class="o">.</span><span class="vm">__name__</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">:</span>
            <span class="n">c</span><span class="p">[</span><span class="s1">&#39;exception_value&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">force_text</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span><span class="p">,</span> <span class="n">errors</span><span class="o">=</span><span class="s1">&#39;replace&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">frames</span><span class="p">:</span>
            <span class="n">c</span><span class="p">[</span><span class="s1">&#39;lastframe&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">frames</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">c</span>

    <span class="k">def</span> <span class="nf">get_traceback_html</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="s2">&quot;Return HTML version of debug 500 HTTP error page.&quot;</span>
        <span class="n">t</span> <span class="o">=</span> <span class="n">DEBUG_ENGINE</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">TECHNICAL_500_TEMPLATE</span><span class="p">)</span>
        <span class="n">c</span> <span class="o">=</span> <span class="n">Context</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_traceback_data</span><span class="p">(),</span> <span class="n">use_l10n</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">get_traceback_text</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="s2">&quot;Return plain text version of debug 500 HTTP error page.&quot;</span>
        <span class="n">t</span> <span class="o">=</span> <span class="n">DEBUG_ENGINE</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">TECHNICAL_500_TEXT_TEMPLATE</span><span class="p">)</span>
        <span class="n">c</span> <span class="o">=</span> <span class="n">Context</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_traceback_data</span><span class="p">(),</span> <span class="n">autoescape</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">use_l10n</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_get_lines_from_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">lineno</span><span class="p">,</span> <span class="n">context_lines</span><span class="p">,</span> <span class="n">loader</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">module_name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns context_lines before and after lineno from file.</span>
<span class="sd">        Returns (pre_context_lineno, pre_context, context_line, post_context).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">source</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">if</span> <span class="n">loader</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">loader</span><span class="p">,</span> <span class="s2">&quot;get_source&quot;</span><span class="p">):</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="n">source</span> <span class="o">=</span> <span class="n">loader</span><span class="o">.</span><span class="n">get_source</span><span class="p">(</span><span class="n">module_name</span><span class="p">)</span>
            <span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
                <span class="k">pass</span>
            <span class="k">if</span> <span class="n">source</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">source</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">source</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fp</span><span class="p">:</span>
                    <span class="n">source</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()</span>
            <span class="k">except</span> <span class="p">(</span><span class="ne">OSError</span><span class="p">,</span> <span class="ne">IOError</span><span class="p">):</span>
                <span class="k">pass</span>
        <span class="k">if</span> <span class="n">source</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span><span class="p">,</span> <span class="p">[],</span> <span class="kc">None</span><span class="p">,</span> <span class="p">[]</span>

        <span class="c1"># If we just read the source from a file, or if the loader did not</span>
        <span class="c1"># apply tokenize.detect_encoding to decode the source into a</span>
        <span class="c1"># string, then we should do that ourselves.</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">bytes</span><span class="p">):</span>
            <span class="n">encoding</span> <span class="o">=</span> <span class="s1">&#39;ascii&#39;</span>
            <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">source</span><span class="p">[:</span><span class="mi">2</span><span class="p">]:</span>
                <span class="c1"># File coding may be specified. Match pattern from PEP-263</span>
                <span class="c1"># (http://www.python.org/dev/peps/pep-0263/)</span>
                <span class="n">match</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">br</span><span class="s1">&#39;coding[:=]\s*([-\w.]+)&#39;</span><span class="p">,</span> <span class="n">line</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">match</span><span class="p">:</span>
                    <span class="n">encoding</span> <span class="o">=</span> <span class="n">match</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;ascii&#39;</span><span class="p">)</span>
                    <span class="k">break</span>
            <span class="n">source</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">sline</span><span class="p">,</span> <span class="n">encoding</span><span class="p">,</span> <span class="s1">&#39;replace&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">sline</span> <span class="ow">in</span> <span class="n">source</span><span class="p">]</span>

        <span class="n">lower_bound</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">lineno</span> <span class="o">-</span> <span class="n">context_lines</span><span class="p">)</span>
        <span class="n">upper_bound</span> <span class="o">=</span> <span class="n">lineno</span> <span class="o">+</span> <span class="n">context_lines</span>

        <span class="n">pre_context</span> <span class="o">=</span> <span class="n">source</span><span class="p">[</span><span class="n">lower_bound</span><span class="p">:</span><span class="n">lineno</span><span class="p">]</span>
        <span class="n">context_line</span> <span class="o">=</span> <span class="n">source</span><span class="p">[</span><span class="n">lineno</span><span class="p">]</span>
        <span class="n">post_context</span> <span class="o">=</span> <span class="n">source</span><span class="p">[</span><span class="n">lineno</span> <span class="o">+</span> <span class="mi">1</span><span class="p">:</span><span class="n">upper_bound</span><span class="p">]</span>

        <span class="k">return</span> <span class="n">lower_bound</span><span class="p">,</span> <span class="n">pre_context</span><span class="p">,</span> <span class="n">context_line</span><span class="p">,</span> <span class="n">post_context</span>

    <span class="k">def</span> <span class="nf">get_traceback_frames</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">def</span> <span class="nf">explicit_or_implicit_cause</span><span class="p">(</span><span class="n">exc_value</span><span class="p">):</span>
            <span class="n">explicit</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">exc_value</span><span class="p">,</span> <span class="s1">&#39;__cause__&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="n">implicit</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">exc_value</span><span class="p">,</span> <span class="s1">&#39;__context__&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="k">return</span> <span class="n">explicit</span> <span class="ow">or</span> <span class="n">implicit</span>

        <span class="c1"># Get the exception and all its causes</span>
        <span class="n">exceptions</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">exc_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">exc_value</span>
        <span class="k">while</span> <span class="n">exc_value</span><span class="p">:</span>
            <span class="n">exceptions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exc_value</span><span class="p">)</span>
            <span class="n">exc_value</span> <span class="o">=</span> <span class="n">explicit_or_implicit_cause</span><span class="p">(</span><span class="n">exc_value</span><span class="p">)</span>

        <span class="n">frames</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="c1"># No exceptions were supplied to ExceptionReporter</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">exceptions</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">frames</span>

        <span class="c1"># In case there&#39;s just one exception, take the traceback from self.tb</span>
        <span class="n">exc_value</span> <span class="o">=</span> <span class="n">exceptions</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
        <span class="n">tb</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tb</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">exceptions</span> <span class="k">else</span> <span class="n">exc_value</span><span class="o">.</span><span class="n">__traceback__</span>

        <span class="k">while</span> <span class="n">tb</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># Support for __traceback_hide__ which is used by a few libraries</span>
            <span class="c1"># to hide internal frames.</span>
            <span class="k">if</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_locals</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;__traceback_hide__&#39;</span><span class="p">):</span>
                <span class="n">tb</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_next</span>
                <span class="k">continue</span>
            <span class="n">filename</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_code</span><span class="o">.</span><span class="n">co_filename</span>
            <span class="n">function</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_code</span><span class="o">.</span><span class="n">co_name</span>
            <span class="n">lineno</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_lineno</span> <span class="o">-</span> <span class="mi">1</span>
            <span class="n">loader</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_globals</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;__loader__&#39;</span><span class="p">)</span>
            <span class="n">module_name</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="o">.</span><span class="n">f_globals</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;__name__&#39;</span><span class="p">)</span> <span class="ow">or</span> <span class="s1">&#39;&#39;</span>
            <span class="n">pre_context_lineno</span><span class="p">,</span> <span class="n">pre_context</span><span class="p">,</span> <span class="n">context_line</span><span class="p">,</span> <span class="n">post_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_lines_from_file</span><span class="p">(</span>
                <span class="n">filename</span><span class="p">,</span> <span class="n">lineno</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="n">loader</span><span class="p">,</span> <span class="n">module_name</span><span class="p">,</span>
            <span class="p">)</span>
            <span class="k">if</span> <span class="n">pre_context_lineno</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">frames</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
                    <span class="s1">&#39;exc_cause&#39;</span><span class="p">:</span> <span class="n">explicit_or_implicit_cause</span><span class="p">(</span><span class="n">exc_value</span><span class="p">),</span>
                    <span class="s1">&#39;exc_cause_explicit&#39;</span><span class="p">:</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">exc_value</span><span class="p">,</span> <span class="s1">&#39;__cause__&#39;</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span>
                    <span class="s1">&#39;tb&#39;</span><span class="p">:</span> <span class="n">tb</span><span class="p">,</span>
                    <span class="s1">&#39;type&#39;</span><span class="p">:</span> <span class="s1">&#39;django&#39;</span> <span class="k">if</span> <span class="n">module_name</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;django.&#39;</span><span class="p">)</span> <span class="k">else</span> <span class="s1">&#39;user&#39;</span><span class="p">,</span>
                    <span class="s1">&#39;filename&#39;</span><span class="p">:</span> <span class="n">filename</span><span class="p">,</span>
                    <span class="s1">&#39;function&#39;</span><span class="p">:</span> <span class="n">function</span><span class="p">,</span>
                    <span class="s1">&#39;lineno&#39;</span><span class="p">:</span> <span class="n">lineno</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span>
                    <span class="s1">&#39;vars&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">filter</span><span class="o">.</span><span class="n">get_traceback_frame_variables</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="p">,</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_frame</span><span class="p">),</span>
                    <span class="s1">&#39;id&#39;</span><span class="p">:</span> <span class="nb">id</span><span class="p">(</span><span class="n">tb</span><span class="p">),</span>
                    <span class="s1">&#39;pre_context&#39;</span><span class="p">:</span> <span class="n">pre_context</span><span class="p">,</span>
                    <span class="s1">&#39;context_line&#39;</span><span class="p">:</span> <span class="n">context_line</span><span class="p">,</span>
                    <span class="s1">&#39;post_context&#39;</span><span class="p">:</span> <span class="n">post_context</span><span class="p">,</span>
                    <span class="s1">&#39;pre_context_lineno&#39;</span><span class="p">:</span> <span class="n">pre_context_lineno</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span>
                <span class="p">})</span>

            <span class="c1"># If the traceback for current exception is consumed, try the</span>
            <span class="c1"># other exception.</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_next</span> <span class="ow">and</span> <span class="n">exceptions</span><span class="p">:</span>
                <span class="n">exc_value</span> <span class="o">=</span> <span class="n">exceptions</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
                <span class="n">tb</span> <span class="o">=</span> <span class="n">exc_value</span><span class="o">.</span><span class="n">__traceback__</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">tb</span> <span class="o">=</span> <span class="n">tb</span><span class="o">.</span><span class="n">tb_next</span>

        <span class="k">return</span> <span class="n">frames</span>


<span class="k">def</span> <span class="nf">technical_404_response</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">exception</span><span class="p">):</span>
    <span class="s2">&quot;Create a technical 404 error response. The exception should be the Http404.&quot;</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">error_url</span> <span class="o">=</span> <span class="n">exception</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;path&#39;</span><span class="p">]</span>
    <span class="k">except</span> <span class="p">(</span><span class="ne">IndexError</span><span class="p">,</span> <span class="ne">TypeError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">):</span>
        <span class="n">error_url</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">path_info</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>  <span class="c1"># Trim leading slash</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">tried</span> <span class="o">=</span> <span class="n">exception</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;tried&#39;</span><span class="p">]</span>
    <span class="k">except</span> <span class="p">(</span><span class="ne">IndexError</span><span class="p">,</span> <span class="ne">TypeError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">):</span>
        <span class="n">tried</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">if</span> <span class="p">(</span><span class="ow">not</span> <span class="n">tried</span> <span class="ow">or</span> <span class="p">(</span>                  <span class="c1"># empty URLconf</span>
            <span class="n">request</span><span class="o">.</span><span class="n">path</span> <span class="o">==</span> <span class="s1">&#39;/&#39;</span> <span class="ow">and</span>
            <span class="nb">len</span><span class="p">(</span><span class="n">tried</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span>             <span class="c1"># default URLconf</span>
            <span class="nb">len</span><span class="p">(</span><span class="n">tried</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span>
            <span class="nb">getattr</span><span class="p">(</span><span class="n">tried</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="s1">&#39;app_name&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">tried</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="s1">&#39;namespace&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;admin&#39;</span>
        <span class="p">)):</span>
            <span class="k">return</span> <span class="n">default_urlconf</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>

    <span class="n">urlconf</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="s1">&#39;urlconf&#39;</span><span class="p">,</span> <span class="n">settings</span><span class="o">.</span><span class="n">ROOT_URLCONF</span><span class="p">)</span>
    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">urlconf</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">ModuleType</span><span class="p">):</span>
        <span class="n">urlconf</span> <span class="o">=</span> <span class="n">urlconf</span><span class="o">.</span><span class="vm">__name__</span>

    <span class="n">caller</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">resolver_match</span> <span class="o">=</span> <span class="n">resolve</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">path</span><span class="p">)</span>
    <span class="k">except</span> <span class="n">Resolver404</span><span class="p">:</span>
        <span class="k">pass</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">obj</span> <span class="o">=</span> <span class="n">resolver_match</span><span class="o">.</span><span class="n">func</span>

        <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="s1">&#39;__name__&#39;</span><span class="p">):</span>
            <span class="n">caller</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="vm">__name__</span>
        <span class="k">elif</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="s1">&#39;__class__&#39;</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">obj</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="s1">&#39;__name__&#39;</span><span class="p">):</span>
            <span class="n">caller</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span>

        <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="s1">&#39;__module__&#39;</span><span class="p">):</span>
            <span class="n">module</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="vm">__module__</span>
            <span class="n">caller</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">.</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">module</span><span class="p">,</span> <span class="n">caller</span><span class="p">)</span>

    <span class="n">t</span> <span class="o">=</span> <span class="n">DEBUG_ENGINE</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">TECHNICAL_404_TEMPLATE</span><span class="p">)</span>
    <span class="n">c</span> <span class="o">=</span> <span class="n">Context</span><span class="p">({</span>
        <span class="s1">&#39;urlconf&#39;</span><span class="p">:</span> <span class="n">urlconf</span><span class="p">,</span>
        <span class="s1">&#39;root_urlconf&#39;</span><span class="p">:</span> <span class="n">settings</span><span class="o">.</span><span class="n">ROOT_URLCONF</span><span class="p">,</span>
        <span class="s1">&#39;request_path&#39;</span><span class="p">:</span> <span class="n">error_url</span><span class="p">,</span>
        <span class="s1">&#39;urlpatterns&#39;</span><span class="p">:</span> <span class="n">tried</span><span class="p">,</span>
        <span class="s1">&#39;reason&#39;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">exception</span><span class="p">),</span>
        <span class="s1">&#39;request&#39;</span><span class="p">:</span> <span class="n">request</span><span class="p">,</span>
        <span class="s1">&#39;settings&#39;</span><span class="p">:</span> <span class="n">get_safe_settings</span><span class="p">(),</span>
        <span class="s1">&#39;raising_view_name&#39;</span><span class="p">:</span> <span class="n">caller</span><span class="p">,</span>
    <span class="p">})</span>
    <span class="k">return</span> <span class="n">HttpResponseNotFound</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">c</span><span class="p">),</span> <span class="n">content_type</span><span class="o">=</span><span class="s1">&#39;text/html&#39;</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">default_urlconf</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
    <span class="s2">&quot;Create an empty URLconf 404 error response.&quot;</span>
    <span class="n">t</span> <span class="o">=</span> <span class="n">DEBUG_ENGINE</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">DEFAULT_URLCONF_TEMPLATE</span><span class="p">)</span>
    <span class="n">c</span> <span class="o">=</span> <span class="n">Context</span><span class="p">({</span>
        <span class="s2">&quot;title&quot;</span><span class="p">:</span> <span class="n">_</span><span class="p">(</span><span class="s2">&quot;Welcome to Django&quot;</span><span class="p">),</span>
        <span class="s2">&quot;heading&quot;</span><span class="p">:</span> <span class="n">_</span><span class="p">(</span><span class="s2">&quot;It worked!&quot;</span><span class="p">),</span>
        <span class="s2">&quot;subheading&quot;</span><span class="p">:</span> <span class="n">_</span><span class="p">(</span><span class="s2">&quot;Congratulations on your first Django-powered page.&quot;</span><span class="p">),</span>
        <span class="s2">&quot;instructions&quot;</span><span class="p">:</span> <span class="n">_</span><span class="p">(</span>
            <span class="s2">&quot;Next, start your first app by running &lt;code&gt;python manage.py startapp [app_label]&lt;/code&gt;.&quot;</span>
        <span class="p">),</span>
        <span class="s2">&quot;explanation&quot;</span><span class="p">:</span> <span class="n">_</span><span class="p">(</span>
            <span class="s2">&quot;You&#39;re seeing this message because you have &lt;code&gt;DEBUG = True&lt;/code&gt; in your &quot;</span>
            <span class="s2">&quot;Django settings file and you haven&#39;t configured any URLs. Get to work!&quot;</span>
        <span class="p">),</span>
    <span class="p">})</span>

    <span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">c</span><span class="p">),</span> <span class="n">content_type</span><span class="o">=</span><span class="s1">&#39;text/html&#39;</span><span class="p">)</span>


<span class="c1">#</span>
<span class="c1"># Templates are embedded in the file so that we know the error handler will</span>
<span class="c1"># always work even if the template loader is broken.</span>
<span class="c1">#</span>

<span class="n">TECHNICAL_500_TEMPLATE</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;&quot;&quot;</span>
<span class="s2">&lt;!DOCTYPE html&gt;</span>
<span class="s2">&lt;html lang=&quot;en&quot;&gt;</span>
<span class="s2">&lt;head&gt;</span>
<span class="s2">  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;</span>
<span class="s2">  &lt;meta name=&quot;robots&quot; content=&quot;NONE,NOARCHIVE&quot;&gt;</span>
<span class="s2">  &lt;title&gt;{</span><span class="si">% i</span><span class="s2">f exception_type %}{{ exception_type }}{</span><span class="si">% e</span><span class="s2">lse %}Report{</span><span class="si">% e</span><span class="s2">ndif %}&quot;&quot;&quot;</span>
<span class="sa">r</span><span class="sd">&quot;&quot;&quot;{% if request %} at {{ request.path_info|escape }}{% endif %}&lt;/title&gt;</span>
<span class="sd">  &lt;style type=&quot;text/css&quot;&gt;</span>
<span class="sd">    html * { padding:0; margin:0; }</span>
<span class="sd">    body * { padding:10px 20px; }</span>
<span class="sd">    body * * { padding:0; }</span>
<span class="sd">    body { font:small sans-serif; }</span>
<span class="sd">    body&gt;div { border-bottom:1px solid #ddd; }</span>
<span class="sd">    h1 { font-weight:normal; }</span>
<span class="sd">    h2 { margin-bottom:.8em; }</span>
<span class="sd">    h2 span { font-size:80%; color:#666; font-weight:normal; }</span>
<span class="sd">    h3 { margin:1em 0 .5em 0; }</span>
<span class="sd">    h4 { margin:0 0 .5em 0; font-weight: normal; }</span>
<span class="sd">    code, pre { font-size: 100%; white-space: pre-wrap; }</span>
<span class="sd">    table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }</span>
<span class="sd">    tbody td, tbody th { vertical-align:top; padding:2px 3px; }</span>
<span class="sd">    thead th {</span>
<span class="sd">      padding:1px 6px 1px 3px; background:#fefefe; text-align:left;</span>
<span class="sd">      font-weight:normal; font-size:11px; border:1px solid #ddd;</span>
<span class="sd">    }</span>
<span class="sd">    tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }</span>
<span class="sd">    table.vars { margin:5px 0 2px 40px; }</span>
<span class="sd">    table.vars td, table.req td { font-family:monospace; }</span>
<span class="sd">    table td.code { width:100%; }</span>
<span class="sd">    table td.code pre { overflow:hidden; }</span>
<span class="sd">    table.source th { color:#666; }</span>
<span class="sd">    table.source td { font-family:monospace; white-space:pre; border-bottom:1px solid #eee; }</span>
<span class="sd">    ul.traceback { list-style-type:none; color: #222; }</span>
<span class="sd">    ul.traceback li.frame { padding-bottom:1em; color:#666; }</span>
<span class="sd">    ul.traceback li.user { background-color:#e0e0e0; color:#000 }</span>
<span class="sd">    div.context { padding:10px 0; overflow:hidden; }</span>
<span class="sd">    div.context ol { padding-left:30px; margin:0 10px; list-style-position: inside; }</span>
<span class="sd">    div.context ol li { font-family:monospace; white-space:pre; color:#777; cursor:pointer; padding-left: 2px; }</span>
<span class="sd">    div.context ol li pre { display:inline; }</span>
<span class="sd">    div.context ol.context-line li { color:#505050; background-color:#dfdfdf; padding: 3px 2px; }</span>
<span class="sd">    div.context ol.context-line li span { position:absolute; right:32px; }</span>
<span class="sd">    .user div.context ol.context-line li { background-color:#bbb; color:#000; }</span>
<span class="sd">    .user div.context ol li { color:#666; }</span>
<span class="sd">    div.commands { margin-left: 40px; }</span>
<span class="sd">    div.commands a { color:#555; text-decoration:none; }</span>
<span class="sd">    .user div.commands a { color: black; }</span>
<span class="sd">    #summary { background: #ffc; }</span>
<span class="sd">    #summary h2 { font-weight: normal; color: #666; }</span>
<span class="sd">    #explanation { background:#eee; }</span>
<span class="sd">    #template, #template-not-exist { background:#f6f6f6; }</span>
<span class="sd">    #template-not-exist ul { margin: 0 0 10px 20px; }</span>
<span class="sd">    #template-not-exist .postmortem-section { margin-bottom: 3px; }</span>
<span class="sd">    #unicode-hint { background:#eee; }</span>
<span class="sd">    #traceback { background:#eee; }</span>
<span class="sd">    #requestinfo { background:#f6f6f6; padding-left:120px; }</span>
<span class="sd">    #summary table { border:none; background:transparent; }</span>
<span class="sd">    #requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }</span>
<span class="sd">    #requestinfo h3 { margin-bottom:-1em; }</span>
<span class="sd">    .error { background: #ffc; }</span>
<span class="sd">    .specific { color:#cc3300; font-weight:bold; }</span>
<span class="sd">    h2 span.commands { font-size:.7em;}</span>
<span class="sd">    span.commands a:link {color:#5E5694;}</span>
<span class="sd">    pre.exception_value { font-family: sans-serif; color: #666; font-size: 1.5em; margin: 10px 0 10px 0; }</span>
<span class="sd">    .append-bottom { margin-bottom: 10px; }</span>
<span class="sd">  &lt;/style&gt;</span>
<span class="sd">  {% if not is_email %}</span>
<span class="sd">  &lt;script type=&quot;text/javascript&quot;&gt;</span>
<span class="sd">  //&lt;!--</span>
<span class="sd">    function getElementsByClassName(oElm, strTagName, strClassName){</span>
<span class="sd">        // Written by Jonathan Snook, http://www.snook.ca/jon; Add-ons by Robert Nyman, http://www.robertnyman.com</span>
<span class="sd">        var arrElements = (strTagName == &quot;*&quot; &amp;&amp; document.all)? document.all :</span>
<span class="sd">        oElm.getElementsByTagName(strTagName);</span>
<span class="sd">        var arrReturnElements = new Array();</span>
<span class="sd">        strClassName = strClassName.replace(/\-/g, &quot;\\-&quot;);</span>
<span class="sd">        var oRegExp = new RegExp(&quot;(^|\\s)&quot; + strClassName + &quot;(\\s|$)&quot;);</span>
<span class="sd">        var oElement;</span>
<span class="sd">        for(var i=0; i&lt;arrElements.length; i++){</span>
<span class="sd">            oElement = arrElements[i];</span>
<span class="sd">            if(oRegExp.test(oElement.className)){</span>
<span class="sd">                arrReturnElements.push(oElement);</span>
<span class="sd">            }</span>
<span class="sd">        }</span>
<span class="sd">        return (arrReturnElements)</span>
<span class="sd">    }</span>
<span class="sd">    function hideAll(elems) {</span>
<span class="sd">      for (var e = 0; e &lt; elems.length; e++) {</span>
<span class="sd">        elems[e].style.display = &#39;none&#39;;</span>
<span class="sd">      }</span>
<span class="sd">    }</span>
<span class="sd">    window.onload = function() {</span>
<span class="sd">      hideAll(getElementsByClassName(document, &#39;table&#39;, &#39;vars&#39;));</span>
<span class="sd">      hideAll(getElementsByClassName(document, &#39;ol&#39;, &#39;pre-context&#39;));</span>
<span class="sd">      hideAll(getElementsByClassName(document, &#39;ol&#39;, &#39;post-context&#39;));</span>
<span class="sd">      hideAll(getElementsByClassName(document, &#39;div&#39;, &#39;pastebin&#39;));</span>
<span class="sd">    }</span>
<span class="sd">    function toggle() {</span>
<span class="sd">      for (var i = 0; i &lt; arguments.length; i++) {</span>
<span class="sd">        var e = document.getElementById(arguments[i]);</span>
<span class="sd">        if (e) {</span>
<span class="sd">          e.style.display = e.style.display == &#39;none&#39; ? &#39;block&#39;: &#39;none&#39;;</span>
<span class="sd">        }</span>
<span class="sd">      }</span>
<span class="sd">      return false;</span>
<span class="sd">    }</span>
<span class="sd">    function varToggle(link, id) {</span>
<span class="sd">      toggle(&#39;v&#39; + id);</span>
<span class="sd">      var s = link.getElementsByTagName(&#39;span&#39;)[0];</span>
<span class="sd">      var uarr = String.fromCharCode(0x25b6);</span>
<span class="sd">      var darr = String.fromCharCode(0x25bc);</span>
<span class="sd">      s.textContent = s.textContent == uarr ? darr : uarr;</span>
<span class="sd">      return false;</span>
<span class="sd">    }</span>
<span class="sd">    function switchPastebinFriendly(link) {</span>
<span class="sd">      s1 = &quot;Switch to copy-and-paste view&quot;;</span>
<span class="sd">      s2 = &quot;Switch back to interactive view&quot;;</span>
<span class="sd">      link.textContent = link.textContent.trim() == s1 ? s2: s1;</span>
<span class="sd">      toggle(&#39;browserTraceback&#39;, &#39;pastebinTraceback&#39;);</span>
<span class="sd">      return false;</span>
<span class="sd">    }</span>
<span class="sd">    //--&gt;</span>
<span class="sd">  &lt;/script&gt;</span>
<span class="sd">  {% endif %}</span>
<span class="sd">&lt;/head&gt;</span>
<span class="sd">&lt;body&gt;</span>
<span class="sd">&lt;div id=&quot;summary&quot;&gt;</span>
<span class="sd">  &lt;h1&gt;{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}&quot;&quot;&quot;</span>
  <span class="sd">&quot;&quot;&quot;{% if request %} at {{ request.path_info|escape }}{% endif %}&lt;/h1&gt;</span>
<span class="sd">  &lt;pre class=&quot;exception_value&quot;&gt;&quot;&quot;&quot;</span>
 <span class="sd">&quot;&quot;&quot;{% if exception_value %}{{ exception_value|force_escape }}{% else %}No exception message supplied{% endif %}&quot;&quot;&quot;</span>
<span class="sd">&quot;&quot;&quot;&lt;/pre&gt;</span>
<span class="sd">  &lt;table class=&quot;meta&quot;&gt;</span>
<span class="sd">{% if request %}</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Request Method:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;{{ request.META.REQUEST_METHOD }}&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Request URL:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;{{ request.get_raw_uri|escape }}&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">{% endif %}</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Django Version:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;{{ django_version_info }}&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">{% if exception_type %}</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Exception Type:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;{{ exception_type }}&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">{% endif %}</span>
<span class="sd">{% if exception_type and exception_value %}</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Exception Value:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;&lt;pre&gt;{{ exception_value|force_escape }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">{% endif %}</span>
<span class="sd">{% if lastframe %}</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Exception Location:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">{% endif %}</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Python Executable:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;{{ sys_executable|escape }}&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Python Version:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;{{ sys_version_info }}&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Python Path:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;&lt;pre&gt;{{ sys_path|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">    &lt;tr&gt;</span>
<span class="sd">      &lt;th&gt;Server time:&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;{{server_time|date:&quot;r&quot;}}&lt;/td&gt;</span>
<span class="sd">    &lt;/tr&gt;</span>
<span class="sd">  &lt;/table&gt;</span>
<span class="sd">&lt;/div&gt;</span>
<span class="sd">{% if unicode_hint %}</span>
<span class="sd">&lt;div id=&quot;unicode-hint&quot;&gt;</span>
<span class="sd">    &lt;h2&gt;Unicode error hint&lt;/h2&gt;</span>
<span class="sd">    &lt;p&gt;The string that could not be encoded/decoded was: &lt;strong&gt;{{ unicode_hint|force_escape }}&lt;/strong&gt;&lt;/p&gt;</span>
<span class="sd">&lt;/div&gt;</span>
<span class="sd">{% endif %}</span>
<span class="sd">{% if template_does_not_exist %}</span>
<span class="sd">&lt;div id=&quot;template-not-exist&quot;&gt;</span>
<span class="sd">    &lt;h2&gt;Template-loader postmortem&lt;/h2&gt;</span>
<span class="sd">    {% if postmortem %}</span>
<span class="sd">        &lt;p class=&quot;append-bottom&quot;&gt;Django tried loading these templates, in this order:&lt;/p&gt;</span>
<span class="sd">        {% for entry in postmortem %}</span>
<span class="sd">            &lt;p class=&quot;postmortem-section&quot;&gt;Using engine &lt;code&gt;{{ entry.backend.name }}&lt;/code&gt;:&lt;/p&gt;</span>
<span class="sd">            &lt;ul&gt;</span>
<span class="sd">                {% if entry.tried %}</span>
<span class="sd">                    {% for attempt in entry.tried %}</span>
<span class="sd">                        &lt;li&gt;&lt;code&gt;{{ attempt.0.loader_name }}&lt;/code&gt;: {{ attempt.0.name }} ({{ attempt.1 }})&lt;/li&gt;</span>
<span class="sd">                    {% endfor %}</span>
<span class="sd">                {% else %}</span>
<span class="sd">                    &lt;li&gt;This engine did not provide a list of tried templates.&lt;/li&gt;</span>
<span class="sd">                {% endif %}</span>
<span class="sd">            &lt;/ul&gt;</span>
<span class="sd">        {% endfor %}</span>
<span class="sd">    {% else %}</span>
<span class="sd">        &lt;p&gt;No templates were found because your &#39;TEMPLATES&#39; setting is not configured.&lt;/p&gt;</span>
<span class="sd">    {% endif %}</span>
<span class="sd">&lt;/div&gt;</span>
<span class="sd">{% endif %}</span>
<span class="sd">{% if template_info %}</span>
<span class="sd">&lt;div id=&quot;template&quot;&gt;</span>
<span class="sd">   &lt;h2&gt;Error during template rendering&lt;/h2&gt;</span>
<span class="sd">   &lt;p&gt;In template &lt;code&gt;{{ template_info.name }}&lt;/code&gt;, error at line &lt;strong&gt;{{ template_info.line }}&lt;/strong&gt;&lt;/p&gt;</span>
<span class="sd">   &lt;h3&gt;{{ template_info.message }}&lt;/h3&gt;</span>
<span class="sd">   &lt;table class=&quot;source{% if template_info.top %} cut-top{% endif %}</span>
<span class="sd">      {% if template_info.bottom != template_info.total %} cut-bottom{% endif %}&quot;&gt;</span>
<span class="sd">   {% for source_line in template_info.source_lines %}</span>
<span class="sd">   {% if source_line.0 == template_info.line %}</span>
<span class="sd">   &lt;tr class=&quot;error&quot;&gt;&lt;th&gt;{{ source_line.0 }}&lt;/th&gt;</span>
<span class="sd">     &lt;td&gt;{{ template_info.before }}&quot;&quot;&quot;</span>
      <span class="sd">&quot;&quot;&quot;&lt;span class=&quot;specific&quot;&gt;{{ template_info.during }}&lt;/span&gt;&quot;&quot;&quot;</span>
      <span class="sd">&quot;&quot;&quot;{{ template_info.after }}&lt;/td&gt;</span>
<span class="sd">   &lt;/tr&gt;</span>
<span class="sd">   {% else %}</span>
<span class="sd">      &lt;tr&gt;&lt;th&gt;{{ source_line.0 }}&lt;/th&gt;</span>
<span class="sd">      &lt;td&gt;{{ source_line.1 }}&lt;/td&gt;&lt;/tr&gt;</span>
<span class="sd">   {% endif %}</span>
<span class="sd">   {% endfor %}</span>
<span class="sd">   &lt;/table&gt;</span>
<span class="sd">&lt;/div&gt;</span>
<span class="sd">{% endif %}</span>
<span class="sd">{% if frames %}</span>
<span class="sd">&lt;div id=&quot;traceback&quot;&gt;</span>
<span class="sd">  &lt;h2&gt;Traceback &lt;span class=&quot;commands&quot;&gt;{% if not is_email %}&lt;a href=&quot;#&quot; onclick=&quot;return switchPastebinFriendly(this);&quot;&gt;</span>
<span class="sd">    Switch to copy-and-paste view&lt;/a&gt;&lt;/span&gt;{% endif %}</span>
<span class="sd">  &lt;/h2&gt;</span>
<span class="sd">  {% autoescape off %}</span>
<span class="sd">  &lt;div id=&quot;browserTraceback&quot;&gt;</span>
<span class="sd">    &lt;ul class=&quot;traceback&quot;&gt;</span>
<span class="sd">      {% for frame in frames %}</span>
<span class="sd">        {% ifchanged frame.exc_cause %}{% if frame.exc_cause %}</span>
<span class="sd">          &lt;li&gt;&lt;h3&gt;</span>
<span class="sd">          {% if frame.exc_cause_explicit %}</span>
<span class="sd">            The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception:</span>
<span class="sd">          {% else %}</span>
<span class="sd">            During handling of the above exception ({{ frame.exc_cause }}), another exception occurred:</span>
<span class="sd">          {% endif %}</span>
<span class="sd">        &lt;/h3&gt;&lt;/li&gt;</span>
<span class="sd">        {% endif %}{% endifchanged %}</span>
<span class="sd">        &lt;li class=&quot;frame {{ frame.type }}&quot;&gt;</span>
<span class="sd">          &lt;code&gt;{{ frame.filename|escape }}&lt;/code&gt; in &lt;code&gt;{{ frame.function|escape }}&lt;/code&gt;</span>

<span class="sd">          {% if frame.context_line %}</span>
<span class="sd">            &lt;div class=&quot;context&quot; id=&quot;c{{ frame.id }}&quot;&gt;</span>
<span class="sd">              {% if frame.pre_context and not is_email %}</span>
<span class="sd">                &lt;ol start=&quot;{{ frame.pre_context_lineno }}&quot; class=&quot;pre-context&quot; id=&quot;pre{{ frame.id }}&quot;&gt;</span>
<span class="sd">                {% for line in frame.pre_context %}</span>
<span class="sd">                  &lt;li onclick=&quot;toggle(&#39;pre{{ frame.id }}&#39;, &#39;post{{ frame.id }}&#39;)&quot;&gt;&lt;pre&gt;{{ line|escape }}&lt;/pre&gt;&lt;/li&gt;</span>
<span class="sd">                {% endfor %}</span>
<span class="sd">                &lt;/ol&gt;</span>
<span class="sd">              {% endif %}</span>
<span class="sd">              &lt;ol start=&quot;{{ frame.lineno }}&quot; class=&quot;context-line&quot;&gt;</span>
<span class="sd">                &lt;li onclick=&quot;toggle(&#39;pre{{ frame.id }}&#39;, &#39;post{{ frame.id }}&#39;)&quot;&gt;&lt;pre&gt;</span>
<span class="sd">&quot;&quot;&quot;</span>            <span class="s2">&quot;&quot;&quot;{{ frame.context_line|escape }}&lt;/pre&gt;{</span><span class="si">% i</span><span class="s2">f not is_email %} &lt;span&gt;...&lt;/span&gt;{</span><span class="si">% e</span><span class="s2">ndif %}&lt;/li&gt;&lt;/ol&gt;</span>
<span class="s2">              {</span><span class="si">% i</span><span class="s2">f frame.post_context and not is_email  %}</span>
<span class="s2">                &lt;ol start=&#39;{{ frame.lineno|add:&quot;1&quot; }}&#39; class=&quot;post-context&quot; id=&quot;post{{ frame.id }}&quot;&gt;</span>
<span class="s2">                  {</span><span class="si">% f</span><span class="s2">or line in frame.post_context %}</span>
<span class="s2">                  &lt;li onclick=&quot;toggle(&#39;pre{{ frame.id }}&#39;, &#39;post{{ frame.id }}&#39;)&quot;&gt;&lt;pre&gt;{{ line|escape }}&lt;/pre&gt;&lt;/li&gt;</span>
<span class="s2">                  {</span><span class="si">% e</span><span class="s2">ndfor %}</span>
<span class="s2">              &lt;/ol&gt;</span>
<span class="s2">              {</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">            &lt;/div&gt;</span>
<span class="s2">          {</span><span class="si">% e</span><span class="s2">ndif %}</span>

<span class="s2">          {</span><span class="si">% i</span><span class="s2">f frame.vars %}</span>
<span class="s2">            &lt;div class=&quot;commands&quot;&gt;</span>
<span class="s2">                {</span><span class="si">% i</span><span class="s2">f is_email %}</span>
<span class="s2">                    &lt;h2&gt;Local Vars&lt;/h2&gt;</span>
<span class="s2">                {</span><span class="si">% e</span><span class="s2">lse %}</span>
<span class="s2">                    &lt;a href=&quot;#&quot; onclick=&quot;return varToggle(this, &#39;{{ frame.id }}&#39;)&quot;&gt;&lt;span&gt;&amp;#x25b6;&lt;/span&gt; Local vars&lt;/a&gt;</span>
<span class="s2">                {</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">            &lt;/div&gt;</span>
<span class="s2">            &lt;table class=&quot;vars&quot; id=&quot;v{{ frame.id }}&quot;&gt;</span>
<span class="s2">              &lt;thead&gt;</span>
<span class="s2">                &lt;tr&gt;</span>
<span class="s2">                  &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="s2">                  &lt;th&gt;Value&lt;/th&gt;</span>
<span class="s2">                &lt;/tr&gt;</span>
<span class="s2">              &lt;/thead&gt;</span>
<span class="s2">              &lt;tbody&gt;</span>
<span class="s2">                {</span><span class="si">% f</span><span class="s2">or var in frame.vars|dictsort:0 %}</span>
<span class="s2">                  &lt;tr&gt;</span>
<span class="s2">                    &lt;td&gt;{{ var.0|force_escape }}&lt;/td&gt;</span>
<span class="s2">                    &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1 }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="s2">                  &lt;/tr&gt;</span>
<span class="s2">                {</span><span class="si">% e</span><span class="s2">ndfor %}</span>
<span class="s2">              &lt;/tbody&gt;</span>
<span class="s2">            &lt;/table&gt;</span>
<span class="s2">          {</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">        &lt;/li&gt;</span>
<span class="s2">      {</span><span class="si">% e</span><span class="s2">ndfor %}</span>
<span class="s2">    &lt;/ul&gt;</span>
<span class="s2">  &lt;/div&gt;</span>
<span class="s2">  {</span><span class="si">% e</span><span class="s2">ndautoescape %}</span>
<span class="s2">  &lt;form action=&quot;http://dpaste.com/&quot; name=&quot;pasteform&quot; id=&quot;pasteform&quot; method=&quot;post&quot;&gt;</span>
<span class="s2">{</span><span class="si">% i</span><span class="s2">f not is_email %}</span>
<span class="s2">  &lt;div id=&quot;pastebinTraceback&quot; class=&quot;pastebin&quot;&gt;</span>
<span class="s2">    &lt;input type=&quot;hidden&quot; name=&quot;language&quot; value=&quot;PythonConsole&quot;&gt;</span>
<span class="s2">    &lt;input type=&quot;hidden&quot; name=&quot;title&quot;</span>
<span class="s2">      value=&quot;{{ exception_type|escape }}{</span><span class="si">% i</span><span class="s2">f request %} at {{ request.path_info|escape }}{</span><span class="si">% e</span><span class="s2">ndif %}&quot;&gt;</span>
<span class="s2">    &lt;input type=&quot;hidden&quot; name=&quot;source&quot; value=&quot;Django Dpaste Agent&quot;&gt;</span>
<span class="s2">    &lt;input type=&quot;hidden&quot; name=&quot;poster&quot; value=&quot;Django&quot;&gt;</span>
<span class="s2">    &lt;textarea name=&quot;content&quot; id=&quot;traceback_area&quot; cols=&quot;140&quot; rows=&quot;25&quot;&gt;</span>
<span class="s2">Environment:</span>

<span class="s2">{</span><span class="si">% i</span><span class="s2">f request %}</span>
<span class="s2">Request Method: {{ request.META.REQUEST_METHOD }}</span>
<span class="s2">Request URL: {{ request.get_raw_uri|escape }}</span>
<span class="s2">{</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">Django Version: {{ django_version_info }}</span>
<span class="s2">Python Version: {{ sys_version_info }}</span>
<span class="s2">Installed Applications:</span>
<span class="s2">{{ settings.INSTALLED_APPS|pprint }}</span>
<span class="s2">Installed Middleware:</span>
<span class="s2">{{ settings.MIDDLEWARE|pprint }}&quot;&quot;&quot;</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="sd">{% if template_does_not_exist %}Template loader postmortem</span>
<span class="sd">{% if postmortem %}Django tried loading these templates, in this order:</span>
<span class="sd">{% for entry in postmortem %}</span>
<span class="sd">Using engine {{ entry.backend.name }}:</span>
<span class="sd">{% if entry.tried %}{% for attempt in entry.tried %}&quot;&quot;&quot;</span>
<span class="sd">&quot;&quot;&quot;    * {{ attempt.0.loader_name }}: {{ attempt.0.name }} ({{ attempt.1 }})</span>
<span class="sd">{% endfor %}{% else %}    This engine did not provide a list of tried templates.</span>
<span class="sd">{% endif %}{% endfor %}</span>
<span class="sd">{% else %}No templates were found because your &#39;TEMPLATES&#39; setting is not configured.</span>
<span class="sd">{% endif %}{% endif %}{% if template_info %}</span>
<span class="sd">Template error:</span>
<span class="sd">In template {{ template_info.name }}, error at line {{ template_info.line }}</span>
<span class="sd">   {{ template_info.message }}&quot;&quot;&quot;</span>
<span class="s2">&quot;{</span><span class="si">% f</span><span class="s2">or source_line in template_info.source_lines %}&quot;</span>
<span class="s2">&quot;{</span><span class="si">% i</span><span class="s2">f source_line.0 == template_info.line %}&quot;</span>
<span class="s2">&quot;   {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}&quot;</span>
<span class="s2">&quot;{</span><span class="si">% e</span><span class="s2">lse %}&quot;</span>
<span class="s2">&quot;   {{ source_line.0 }} : {{ source_line.1 }}&quot;</span>
<span class="sd">&quot;&quot;&quot;{% endif %}{% endfor %}{% endif %}</span>

<span class="sd">Traceback:{% for frame in frames %}</span>
<span class="sd">{% ifchanged frame.exc_cause %}{% if frame.exc_cause %}{% if frame.exc_cause_explicit %}</span>
<span class="sd">The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception:</span>
<span class="sd">{% else %}</span>
<span class="sd">During handling of the above exception ({{ frame.exc_cause }}), another exception occurred:</span>
<span class="sd">{% endif %}{% endif %}{% endifchanged %}</span>
<span class="sd">File &quot;{{ frame.filename|escape }}&quot; in {{ frame.function|escape }}</span>
<span class="sd">{% if frame.context_line %}  {{ frame.lineno }}. {{ frame.context_line|escape }}{% endif %}{% endfor %}</span>

<span class="sd">Exception Type: {{ exception_type|escape }}{% if request %} at {{ request.path_info|escape }}{% endif %}</span>
<span class="sd">Exception Value: {{ exception_value|force_escape }}</span>
<span class="sd">&lt;/textarea&gt;</span>
<span class="sd">  &lt;br&gt;&lt;br&gt;</span>
<span class="sd">  &lt;input type=&quot;submit&quot; value=&quot;Share this traceback on a public website&quot;&gt;</span>
<span class="sd">  &lt;/div&gt;</span>
<span class="sd">&lt;/form&gt;</span>
<span class="sd">&lt;/div&gt;</span>
<span class="sd">{% endif %}</span>
<span class="sd">{% endif %}</span>

<span class="sd">&lt;div id=&quot;requestinfo&quot;&gt;</span>
<span class="sd">  &lt;h2&gt;Request information&lt;/h2&gt;</span>

<span class="sd">{% if request %}</span>
<span class="sd">  {% if user_str %}</span>
<span class="sd">    &lt;h3 id=&quot;user-info&quot;&gt;USER&lt;/h3&gt;</span>
<span class="sd">    &lt;p&gt;{{ user_str }}&lt;/p&gt;</span>
<span class="sd">  {% endif %}</span>

<span class="sd">  &lt;h3 id=&quot;get-info&quot;&gt;GET&lt;/h3&gt;</span>
<span class="sd">  {% if request.GET %}</span>
<span class="sd">    &lt;table class=&quot;req&quot;&gt;</span>
<span class="sd">      &lt;thead&gt;</span>
<span class="sd">        &lt;tr&gt;</span>
<span class="sd">          &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="sd">          &lt;th&gt;Value&lt;/th&gt;</span>
<span class="sd">        &lt;/tr&gt;</span>
<span class="sd">      &lt;/thead&gt;</span>
<span class="sd">      &lt;tbody&gt;</span>
<span class="sd">        {% for k, v in request_GET_items %}</span>
<span class="sd">          &lt;tr&gt;</span>
<span class="sd">            &lt;td&gt;{{ k }}&lt;/td&gt;</span>
<span class="sd">            &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ v|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="sd">          &lt;/tr&gt;</span>
<span class="sd">        {% endfor %}</span>
<span class="sd">      &lt;/tbody&gt;</span>
<span class="sd">    &lt;/table&gt;</span>
<span class="sd">  {% else %}</span>
<span class="sd">    &lt;p&gt;No GET data&lt;/p&gt;</span>
<span class="sd">  {% endif %}</span>

<span class="sd">  &lt;h3 id=&quot;post-info&quot;&gt;POST&lt;/h3&gt;</span>
<span class="sd">  {% if filtered_POST_items %}</span>
<span class="sd">    &lt;table class=&quot;req&quot;&gt;</span>
<span class="sd">      &lt;thead&gt;</span>
<span class="sd">        &lt;tr&gt;</span>
<span class="sd">          &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="sd">          &lt;th&gt;Value&lt;/th&gt;</span>
<span class="sd">        &lt;/tr&gt;</span>
<span class="sd">      &lt;/thead&gt;</span>
<span class="sd">      &lt;tbody&gt;</span>
<span class="sd">        {% for k, v in filtered_POST_items %}</span>
<span class="sd">          &lt;tr&gt;</span>
<span class="sd">            &lt;td&gt;{{ k }}&lt;/td&gt;</span>
<span class="sd">            &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ v|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="sd">          &lt;/tr&gt;</span>
<span class="sd">        {% endfor %}</span>
<span class="sd">      &lt;/tbody&gt;</span>
<span class="sd">    &lt;/table&gt;</span>
<span class="sd">  {% else %}</span>
<span class="sd">    &lt;p&gt;No POST data&lt;/p&gt;</span>
<span class="sd">  {% endif %}</span>
<span class="sd">  &lt;h3 id=&quot;files-info&quot;&gt;FILES&lt;/h3&gt;</span>
<span class="sd">  {% if request.FILES %}</span>
<span class="sd">    &lt;table class=&quot;req&quot;&gt;</span>
<span class="sd">        &lt;thead&gt;</span>
<span class="sd">            &lt;tr&gt;</span>
<span class="sd">                &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="sd">                &lt;th&gt;Value&lt;/th&gt;</span>
<span class="sd">            &lt;/tr&gt;</span>
<span class="sd">        &lt;/thead&gt;</span>
<span class="sd">        &lt;tbody&gt;</span>
<span class="sd">            {% for k, v in request_FILES_items %}</span>
<span class="sd">                &lt;tr&gt;</span>
<span class="sd">                    &lt;td&gt;{{ k }}&lt;/td&gt;</span>
<span class="sd">                    &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ v|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="sd">                &lt;/tr&gt;</span>
<span class="sd">            {% endfor %}</span>
<span class="sd">        &lt;/tbody&gt;</span>
<span class="sd">    &lt;/table&gt;</span>
<span class="sd">  {% else %}</span>
<span class="sd">    &lt;p&gt;No FILES data&lt;/p&gt;</span>
<span class="sd">  {% endif %}</span>


<span class="sd">  &lt;h3 id=&quot;cookie-info&quot;&gt;COOKIES&lt;/h3&gt;</span>
<span class="sd">  {% if request.COOKIES %}</span>
<span class="sd">    &lt;table class=&quot;req&quot;&gt;</span>
<span class="sd">      &lt;thead&gt;</span>
<span class="sd">        &lt;tr&gt;</span>
<span class="sd">          &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="sd">          &lt;th&gt;Value&lt;/th&gt;</span>
<span class="sd">        &lt;/tr&gt;</span>
<span class="sd">      &lt;/thead&gt;</span>
<span class="sd">      &lt;tbody&gt;</span>
<span class="sd">        {% for k, v in request_COOKIES_items %}</span>
<span class="sd">          &lt;tr&gt;</span>
<span class="sd">            &lt;td&gt;{{ k }}&lt;/td&gt;</span>
<span class="sd">            &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ v|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="sd">          &lt;/tr&gt;</span>
<span class="sd">        {% endfor %}</span>
<span class="sd">      &lt;/tbody&gt;</span>
<span class="sd">    &lt;/table&gt;</span>
<span class="sd">  {% else %}</span>
<span class="sd">    &lt;p&gt;No cookie data&lt;/p&gt;</span>
<span class="sd">  {% endif %}</span>

<span class="sd">  &lt;h3 id=&quot;meta-info&quot;&gt;META&lt;/h3&gt;</span>
<span class="sd">  &lt;table class=&quot;req&quot;&gt;</span>
<span class="sd">    &lt;thead&gt;</span>
<span class="sd">      &lt;tr&gt;</span>
<span class="sd">        &lt;th&gt;Variable&lt;/th&gt;</span>
<span class="sd">        &lt;th&gt;Value&lt;/th&gt;</span>
<span class="sd">      &lt;/tr&gt;</span>
<span class="sd">    &lt;/thead&gt;</span>
<span class="sd">    &lt;tbody&gt;</span>
<span class="sd">      {% for var in request.META.items|dictsort:0 %}</span>
<span class="sd">        &lt;tr&gt;</span>
<span class="sd">          &lt;td&gt;{{ var.0 }}&lt;/td&gt;</span>
<span class="sd">          &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="sd">        &lt;/tr&gt;</span>
<span class="sd">      {% endfor %}</span>
<span class="sd">    &lt;/tbody&gt;</span>
<span class="sd">  &lt;/table&gt;</span>
<span class="sd">{% else %}</span>
<span class="sd">  &lt;p&gt;Request data not supplied&lt;/p&gt;</span>
<span class="sd">{% endif %}</span>

<span class="sd">  &lt;h3 id=&quot;settings-info&quot;&gt;Settings&lt;/h3&gt;</span>
<span class="sd">  &lt;h4&gt;Using settings module &lt;code&gt;{{ settings.SETTINGS_MODULE }}&lt;/code&gt;&lt;/h4&gt;</span>
<span class="sd">  &lt;table class=&quot;req&quot;&gt;</span>
<span class="sd">    &lt;thead&gt;</span>
<span class="sd">      &lt;tr&gt;</span>
<span class="sd">        &lt;th&gt;Setting&lt;/th&gt;</span>
<span class="sd">        &lt;th&gt;Value&lt;/th&gt;</span>
<span class="sd">      &lt;/tr&gt;</span>
<span class="sd">    &lt;/thead&gt;</span>
<span class="sd">    &lt;tbody&gt;</span>
<span class="sd">      {% for var in settings.items|dictsort:0 %}</span>
<span class="sd">        &lt;tr&gt;</span>
<span class="sd">          &lt;td&gt;{{ var.0 }}&lt;/td&gt;</span>
<span class="sd">          &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{{ var.1|pprint }}&lt;/pre&gt;&lt;/td&gt;</span>
<span class="sd">        &lt;/tr&gt;</span>
<span class="sd">      {% endfor %}</span>
<span class="sd">    &lt;/tbody&gt;</span>
<span class="sd">  &lt;/table&gt;</span>

<span class="sd">&lt;/div&gt;</span>
<span class="sd">{% if not is_email %}</span>
<span class="sd">  &lt;div id=&quot;explanation&quot;&gt;</span>
<span class="sd">    &lt;p&gt;</span>
<span class="sd">      You&#39;re seeing this error because you have &lt;code&gt;DEBUG = True&lt;/code&gt; in your</span>
<span class="sd">      Django settings file. Change that to &lt;code&gt;False&lt;/code&gt;, and Django will</span>
<span class="sd">      display a standard page generated by the handler for this status code.</span>
<span class="sd">    &lt;/p&gt;</span>
<span class="sd">  &lt;/div&gt;</span>
<span class="sd">{% endif %}</span>
<span class="sd">&lt;/body&gt;</span>
<span class="sd">&lt;/html&gt;</span>
<span class="sd">&quot;&quot;&quot;</span><span class="p">)</span>  <span class="c1"># NOQA</span>

<span class="n">TECHNICAL_500_TEXT_TEMPLATE</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;&quot;&quot;&quot;&quot;&quot;</span>
<span class="sd">&quot;&quot;&quot;{% firstof exception_type &#39;Report&#39; %}{% if request %} at {{ request.path_info }}{% endif %}</span>
<span class="sd">{% firstof exception_value &#39;No exception message supplied&#39; %}</span>
<span class="sd">{% if request %}</span>
<span class="sd">Request Method: {{ request.META.REQUEST_METHOD }}</span>
<span class="sd">Request URL: {{ request.get_raw_uri }}{% endif %}</span>
<span class="sd">Django Version: {{ django_version_info }}</span>
<span class="sd">Python Executable: {{ sys_executable }}</span>
<span class="sd">Python Version: {{ sys_version_info }}</span>
<span class="sd">Python Path: {{ sys_path }}</span>
<span class="sd">Server time: {{server_time|date:&quot;r&quot;}}</span>
<span class="sd">Installed Applications:</span>
<span class="sd">{{ settings.INSTALLED_APPS|pprint }}</span>
<span class="sd">Installed Middleware:</span>
<span class="sd">{{ settings.MIDDLEWARE|pprint }}&quot;&quot;&quot;</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">{% if template_does_not_exist %}Template loader postmortem</span>
<span class="sd">{% if postmortem %}Django tried loading these templates, in this order:</span>
<span class="sd">{% for entry in postmortem %}</span>
<span class="sd">Using engine {{ entry.backend.name }}:</span>
<span class="sd">{% if entry.tried %}{% for attempt in entry.tried %}&quot;&quot;&quot;</span>
<span class="sd">&quot;&quot;&quot;    * {{ attempt.0.loader_name }}: {{ attempt.0.name }} ({{ attempt.1 }})</span>
<span class="sd">{% endfor %}{% else %}    This engine did not provide a list of tried templates.</span>
<span class="sd">{% endif %}{% endfor %}</span>
<span class="sd">{% else %}No templates were found because your &#39;TEMPLATES&#39; setting is not configured.</span>
<span class="sd">{% endif %}</span>
<span class="sd">{% endif %}{% if template_info %}</span>
<span class="sd">Template error:</span>
<span class="sd">In template {{ template_info.name }}, error at line {{ template_info.line }}</span>
<span class="sd">   {{ template_info.message }}</span>
<span class="sd">{% for source_line in template_info.source_lines %}&quot;&quot;&quot;</span>
<span class="s2">&quot;{</span><span class="si">% i</span><span class="s2">f source_line.0 == template_info.line %}&quot;</span>
<span class="s2">&quot;   {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}&quot;</span>
<span class="s2">&quot;{</span><span class="si">% e</span><span class="s2">lse %}&quot;</span>
<span class="s2">&quot;   {{ source_line.0 }} : {{ source_line.1 }}&quot;</span>
<span class="sd">&quot;&quot;&quot;{% endif %}{% endfor %}{% endif %}{% if frames %}</span>

<span class="sd">Traceback:&quot;&quot;&quot;</span>
<span class="s2">&quot;{</span><span class="si">% f</span><span class="s2">or frame in frames %}&quot;</span>
<span class="s2">&quot;{</span><span class="si">% i</span><span class="s2">fchanged frame.exc_cause %}&quot;</span>
<span class="s2">&quot;  {</span><span class="si">% i</span><span class="s2">f frame.exc_cause %}&quot;</span> <span class="s2">&quot;&quot;&quot;</span>
<span class="s2">    {</span><span class="si">% i</span><span class="s2">f frame.exc_cause_explicit %}</span>
<span class="s2">      The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception:</span>
<span class="s2">    {</span><span class="si">% e</span><span class="s2">lse %}</span>
<span class="s2">      During handling of the above exception ({{ frame.exc_cause }}), another exception occurred:</span>
<span class="s2">    {</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">  {</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">{</span><span class="si">% e</span><span class="s2">ndifchanged %}</span>
<span class="s2">File &quot;{{ frame.filename }}&quot; in {{ frame.function }}</span>
<span class="s2">{</span><span class="si">% i</span><span class="s2">f frame.context_line %}  {{ frame.lineno }}. {{ frame.context_line }}{</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">{</span><span class="si">% e</span><span class="s2">ndfor %}</span>
<span class="s2">{</span><span class="si">% i</span><span class="s2">f exception_type %}Exception Type: {{ exception_type }}{</span><span class="si">% i</span><span class="s2">f request %} at {{ request.path_info }}{</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">{</span><span class="si">% i</span><span class="s2">f exception_value %}Exception Value: {{ exception_value }}{</span><span class="si">% e</span><span class="s2">ndif %}{</span><span class="si">% e</span><span class="s2">ndif %}{</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">{</span><span class="si">% i</span><span class="s2">f request %}Request information:</span>
<span class="s2">{</span><span class="si">% i</span><span class="s2">f user_str %}USER: {{ user_str }}{</span><span class="si">% e</span><span class="s2">ndif %}</span>

<span class="s2">GET:{</span><span class="si">% f</span><span class="s2">or k, v in request_GET_items %}</span>
<span class="s2">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s2">mpty %} No GET data{</span><span class="si">% e</span><span class="s2">ndfor %}</span>

<span class="s2">POST:{</span><span class="si">% f</span><span class="s2">or k, v in filtered_POST_items %}</span>
<span class="s2">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s2">mpty %} No POST data{</span><span class="si">% e</span><span class="s2">ndfor %}</span>

<span class="s2">FILES:{</span><span class="si">% f</span><span class="s2">or k, v in request_FILES_items %}</span>
<span class="s2">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s2">mpty %} No FILES data{</span><span class="si">% e</span><span class="s2">ndfor %}</span>

<span class="s2">COOKIES:{</span><span class="si">% f</span><span class="s2">or k, v in request_COOKIES_items %}</span>
<span class="s2">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s2">mpty %} No cookie data{</span><span class="si">% e</span><span class="s2">ndfor %}</span>

<span class="s2">META:{</span><span class="si">% f</span><span class="s2">or k, v in request.META.items|dictsort:0 %}</span>
<span class="s2">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s2">ndfor %}</span>
<span class="s2">{</span><span class="si">% e</span><span class="s2">lse %}Request data not supplied</span>
<span class="s2">{</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">Settings:</span>
<span class="s2">Using settings module {{ settings.SETTINGS_MODULE }}{</span><span class="si">% f</span><span class="s2">or k, v in settings.items|dictsort:0 %}</span>
<span class="s2">{{ k }} = {{ v|stringformat:&quot;r&quot; }}{</span><span class="si">% e</span><span class="s2">ndfor %}</span>

<span class="s2">{</span><span class="si">% i</span><span class="s2">f not is_email %}</span>
<span class="s2">You&#39;re seeing this error because you have DEBUG = True in your</span>
<span class="s2">Django settings file. Change that to False, and Django will</span>
<span class="s2">display a standard page generated by the handler for this status code.</span>
<span class="s2">{</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">&quot;&quot;&quot;</span><span class="p">)</span>  <span class="c1"># NOQA</span>

<span class="n">TECHNICAL_404_TEMPLATE</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span>
<span class="s2">&lt;!DOCTYPE html&gt;</span>
<span class="s2">&lt;html lang=&quot;en&quot;&gt;</span>
<span class="s2">&lt;head&gt;</span>
<span class="s2">  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;</span>
<span class="s2">  &lt;title&gt;Page not found at {{ request.path_info|escape }}&lt;/title&gt;</span>
<span class="s2">  &lt;meta name=&quot;robots&quot; content=&quot;NONE,NOARCHIVE&quot;&gt;</span>
<span class="s2">  &lt;style type=&quot;text/css&quot;&gt;</span>
<span class="s2">    html * { padding:0; margin:0; }</span>
<span class="s2">    body * { padding:10px 20px; }</span>
<span class="s2">    body * * { padding:0; }</span>
<span class="s2">    body { font:small sans-serif; background:#eee; }</span>
<span class="s2">    body&gt;div { border-bottom:1px solid #ddd; }</span>
<span class="s2">    h1 { font-weight:normal; margin-bottom:.4em; }</span>
<span class="s2">    h1 span { font-size:60%; color:#666; font-weight:normal; }</span>
<span class="s2">    table { border:none; border-collapse: collapse; width:100%; }</span>
<span class="s2">    td, th { vertical-align:top; padding:2px 3px; }</span>
<span class="s2">    th { width:12em; text-align:right; color:#666; padding-right:.5em; }</span>
<span class="s2">    #info { background:#f6f6f6; }</span>
<span class="s2">    #info ol { margin: 0.5em 4em; }</span>
<span class="s2">    #info ol li { font-family: monospace; }</span>
<span class="s2">    #summary { background: #ffc; }</span>
<span class="s2">    #explanation { background:#eee; border-bottom: 0px none; }</span>
<span class="s2">  &lt;/style&gt;</span>
<span class="s2">&lt;/head&gt;</span>
<span class="s2">&lt;body&gt;</span>
<span class="s2">  &lt;div id=&quot;summary&quot;&gt;</span>
<span class="s2">    &lt;h1&gt;Page not found &lt;span&gt;(404)&lt;/span&gt;&lt;/h1&gt;</span>
<span class="s2">    &lt;table class=&quot;meta&quot;&gt;</span>
<span class="s2">      &lt;tr&gt;</span>
<span class="s2">        &lt;th&gt;Request Method:&lt;/th&gt;</span>
<span class="s2">        &lt;td&gt;{{ request.META.REQUEST_METHOD }}&lt;/td&gt;</span>
<span class="s2">      &lt;/tr&gt;</span>
<span class="s2">      &lt;tr&gt;</span>
<span class="s2">        &lt;th&gt;Request URL:&lt;/th&gt;</span>
<span class="s2">        &lt;td&gt;{{ request.build_absolute_uri|escape }}&lt;/td&gt;</span>
<span class="s2">      &lt;/tr&gt;</span>
<span class="s2">      {</span><span class="si">% i</span><span class="s2">f raising_view_name %}</span>
<span class="s2">      &lt;tr&gt;</span>
<span class="s2">        &lt;th&gt;Raised by:&lt;/th&gt;</span>
<span class="s2">        &lt;td&gt;{{ raising_view_name }}&lt;/td&gt;</span>
<span class="s2">      &lt;/tr&gt;</span>
<span class="s2">      {</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">    &lt;/table&gt;</span>
<span class="s2">  &lt;/div&gt;</span>
<span class="s2">  &lt;div id=&quot;info&quot;&gt;</span>
<span class="s2">    {</span><span class="si">% i</span><span class="s2">f urlpatterns %}</span>
<span class="s2">      &lt;p&gt;</span>
<span class="s2">      Using the URLconf defined in &lt;code&gt;{{ urlconf }}&lt;/code&gt;,</span>
<span class="s2">      Django tried these URL patterns, in this order:</span>
<span class="s2">      &lt;/p&gt;</span>
<span class="s2">      &lt;ol&gt;</span>
<span class="s2">        {</span><span class="si">% f</span><span class="s2">or pattern in urlpatterns %}</span>
<span class="s2">          &lt;li&gt;</span>
<span class="s2">            {</span><span class="si">% f</span><span class="s2">or pat in pattern %}</span>
<span class="s2">                {{ pat.regex.pattern }}</span>
<span class="s2">                {</span><span class="si">% i</span><span class="s2">f forloop.last and pat.name %}[name=&#39;{{ pat.name }}&#39;]{</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">            {</span><span class="si">% e</span><span class="s2">ndfor %}</span>
<span class="s2">          &lt;/li&gt;</span>
<span class="s2">        {</span><span class="si">% e</span><span class="s2">ndfor %}</span>
<span class="s2">      &lt;/ol&gt;</span>
<span class="s2">      &lt;p&gt;</span>
<span class="s2">        {</span><span class="si">% i</span><span class="s2">f request_path %}</span>
<span class="s2">        The current path, &lt;code&gt;{{ request_path|escape }}&lt;/code&gt;,{</span><span class="si">% e</span><span class="s2">lse %}</span>
<span class="s2">        The empty path{</span><span class="si">% e</span><span class="s2">ndif %} didn&#39;t match any of these.</span>
<span class="s2">      &lt;/p&gt;</span>
<span class="s2">    {</span><span class="si">% e</span><span class="s2">lse %}</span>
<span class="s2">      &lt;p&gt;{{ reason }}&lt;/p&gt;</span>
<span class="s2">    {</span><span class="si">% e</span><span class="s2">ndif %}</span>
<span class="s2">  &lt;/div&gt;</span>

<span class="s2">  &lt;div id=&quot;explanation&quot;&gt;</span>
<span class="s2">    &lt;p&gt;</span>
<span class="s2">      You&#39;re seeing this error because you have &lt;code&gt;DEBUG = True&lt;/code&gt; in</span>
<span class="s2">      your Django settings file. Change that to &lt;code&gt;False&lt;/code&gt;, and Django</span>
<span class="s2">      will display a standard 404 page.</span>
<span class="s2">    &lt;/p&gt;</span>
<span class="s2">  &lt;/div&gt;</span>
<span class="s2">&lt;/body&gt;</span>
<span class="s2">&lt;/html&gt;</span>
<span class="s2">&quot;&quot;&quot;</span>

<span class="n">DEFAULT_URLCONF_TEMPLATE</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span>
<span class="s2">&lt;!DOCTYPE html&gt;</span>
<span class="s2">&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;</span>
<span class="s2">  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;</span>
<span class="s2">  &lt;meta name=&quot;robots&quot; content=&quot;NONE,NOARCHIVE&quot;&gt;&lt;title&gt;{{ title }}&lt;/title&gt;</span>
<span class="s2">  &lt;style type=&quot;text/css&quot;&gt;</span>
<span class="s2">    html * { padding:0; margin:0; }</span>
<span class="s2">    body * { padding:10px 20px; }</span>
<span class="s2">    body * * { padding:0; }</span>
<span class="s2">    body { font:small sans-serif; }</span>
<span class="s2">    body&gt;div { border-bottom:1px solid #ddd; }</span>
<span class="s2">    h1 { font-weight:normal; }</span>
<span class="s2">    h2 { margin-bottom:.8em; }</span>
<span class="s2">    h2 span { font-size:80%; color:#666; font-weight:normal; }</span>
<span class="s2">    h3 { margin:1em 0 .5em 0; }</span>
<span class="s2">    h4 { margin:0 0 .5em 0; font-weight: normal; }</span>
<span class="s2">    table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }</span>
<span class="s2">    tbody td, tbody th { vertical-align:top; padding:2px 3px; }</span>
<span class="s2">    thead th {</span>
<span class="s2">      padding:1px 6px 1px 3px; background:#fefefe; text-align:left;</span>
<span class="s2">      font-weight:normal; font-size:11px; border:1px solid #ddd;</span>
<span class="s2">    }</span>
<span class="s2">    tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }</span>
<span class="s2">    #summary { background: #e0ebff; }</span>
<span class="s2">    #summary h2 { font-weight: normal; color: #666; }</span>
<span class="s2">    #explanation { background:#eee; }</span>
<span class="s2">    #instructions { background:#f6f6f6; }</span>
<span class="s2">    #summary table { border:none; background:transparent; }</span>
<span class="s2">  &lt;/style&gt;</span>
<span class="s2">&lt;/head&gt;</span>

<span class="s2">&lt;body&gt;</span>
<span class="s2">&lt;div id=&quot;summary&quot;&gt;</span>
<span class="s2">  &lt;h1&gt;{{ heading }}&lt;/h1&gt;</span>
<span class="s2">  &lt;h2&gt;{{ subheading }}&lt;/h2&gt;</span>
<span class="s2">&lt;/div&gt;</span>

<span class="s2">&lt;div id=&quot;instructions&quot;&gt;</span>
<span class="s2">  &lt;p&gt;</span>
<span class="s2">    {{ instructions|safe }}</span>
<span class="s2">  &lt;/p&gt;</span>
<span class="s2">&lt;/div&gt;</span>

<span class="s2">&lt;div id=&quot;explanation&quot;&gt;</span>
<span class="s2">  &lt;p&gt;</span>
<span class="s2">    {{ explanation|safe }}</span>
<span class="s2">  &lt;/p&gt;</span>
<span class="s2">&lt;/div&gt;</span>
<span class="s2">&lt;/body&gt;&lt;/html&gt;</span>
<span class="s2">&quot;&quot;&quot;</span>
</pre></div>

          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3>Browse</h3>
  <ul>
    
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../../../index.html">Django 2.0.dev20170216164632 documentation</a>
        
          <ul><li><a href="../../index.html">Module code</a>
        
          <ul><li><a href="../../django.html">django</a>
        
        <ul><li>django.views.debug</li></ul>
        </li></ul></li></ul>
      </li>
  </ul>

<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="../../../search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Feb 16, 2017</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    <a href="../../index.html" title="Module code" accesskey="U">up</a></div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>