Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > bbfc3ae635f1c97b96c5bef8b94bcfb5 > files > 473

python-django-doc-1.5.9-1.2.mga4.noarch.rpm


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Base views &mdash; Django 1.5.9 documentation</title>
    
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '1.5.9',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <link rel="top" title="Django 1.5.9 documentation" href="../../index.html" />
    <link rel="up" title="Class-based views" href="index.html" />
    <link rel="next" title="Generic display views" href="generic-display.html" />
    <link rel="prev" title="Class-based views" href="index.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 = "../templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head>
  <body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../index.html">Django 1.5.9 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">
    &laquo; <a href="index.html" title="Class-based views">previous</a> 
     |
    <a href="../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="generic-display.html" title="Generic display views">next</a> &raquo;</div>
    </div>
    
    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-class-based-views-base">
            
  <div class="section" id="s-base-views">
<span id="base-views"></span><h1>Base views<a class="headerlink" href="#base-views" title="Permalink to this headline">¶</a></h1>
<p>The following three classes provide much of the functionality needed to create
Django views. You may think of them as <em>parent</em> views, which can be used by
themselves or inherited from. They may not provide all the capabilities
required for projects, in which case there are Mixins and Generic class-based
views.</p>
<p>Many of Django&#8217;s built-in class-based views inherit from other class-based
views or various mixins. Because this inheritance chain is very important, the
ancestor classes are  documented under the section title of <strong>Ancestors (MRO)</strong>.
MRO is an acronym for Method Resolution Order.</p>
<div class="section" id="s-view">
<span id="view"></span><h2>View<a class="headerlink" href="#view" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="django.views.generic.base.View">
<em class="property">class </em><tt class="descclassname">django.views.generic.base.</tt><tt class="descname">View</tt><a class="headerlink" href="#django.views.generic.base.View" title="Permalink to this definition">¶</a></dt>
<dd><p>The master class-based base view. All other class-based views inherit from
this base class.</p>
<p><strong>Method Flowchart</strong></p>
<ol class="arabic simple">
<li><a class="reference internal" href="#django.views.generic.base.View.dispatch" title="django.views.generic.base.View.dispatch"><tt class="xref py py-meth docutils literal"><span class="pre">dispatch()</span></tt></a></li>
<li><a class="reference internal" href="#django.views.generic.base.View.http_method_not_allowed" title="django.views.generic.base.View.http_method_not_allowed"><tt class="xref py py-meth docutils literal"><span class="pre">http_method_not_allowed()</span></tt></a></li>
<li><a class="reference internal" href="#django.views.generic.base.View.options" title="django.views.generic.base.View.options"><tt class="xref py py-meth docutils literal"><span class="pre">options()</span></tt></a></li>
</ol>
<p><strong>Example views.py</strong>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.http</span> <span class="kn">import</span> <span class="n">HttpResponse</span>
<span class="kn">from</span> <span class="nn">django.views.generic</span> <span class="kn">import</span> <span class="n">View</span>

<span class="k">class</span> <span class="nc">MyView</span><span class="p">(</span><span class="n">View</span><span class="p">):</span>

    <span class="k">def</span> <span class="nf">get</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="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="s">&#39;Hello, World!&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p><strong>Example urls.py</strong>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.conf.urls</span> <span class="kn">import</span> <span class="n">patterns</span><span class="p">,</span> <span class="n">url</span>

<span class="kn">from</span> <span class="nn">myapp.views</span> <span class="kn">import</span> <span class="n">MyView</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s">&#39;&#39;</span><span class="p">,</span>
    <span class="n">url</span><span class="p">(</span><span class="s">r&#39;^mine/$&#39;</span><span class="p">,</span> <span class="n">MyView</span><span class="o">.</span><span class="n">as_view</span><span class="p">(),</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;my-view&#39;</span><span class="p">),</span>
<span class="p">)</span>
</pre></div>
</div>
<p><strong>Attributes</strong></p>
<dl class="attribute">
<dt id="django.views.generic.base.View.http_method_names">
<tt class="descname">http_method_names</tt><a class="headerlink" href="#django.views.generic.base.View.http_method_names" title="Permalink to this definition">¶</a></dt>
<dd><p>The list of HTTP method names that this view will accept.</p>
<p>Default:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">[</span><span class="s">&#39;get&#39;</span><span class="p">,</span> <span class="s">&#39;post&#39;</span><span class="p">,</span> <span class="s">&#39;put&#39;</span><span class="p">,</span> <span class="s">&#39;delete&#39;</span><span class="p">,</span> <span class="s">&#39;head&#39;</span><span class="p">,</span> <span class="s">&#39;options&#39;</span><span class="p">,</span> <span class="s">&#39;trace&#39;</span><span class="p">]</span>
</pre></div>
</div>
</dd></dl>

<p><strong>Methods</strong></p>
<dl class="classmethod">
<dt id="django.views.generic.base.View.as_view">
<em class="property">classmethod </em><tt class="descname">as_view</tt>(<em>**initkwargs</em>)<a class="headerlink" href="#django.views.generic.base.View.as_view" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a callable view that takes a request and returns a response:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">response</span> <span class="o">=</span> <span class="n">MyView</span><span class="o">.</span><span class="n">as_view</span><span class="p">()(</span><span class="n">request</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="django.views.generic.base.View.dispatch">
<tt class="descname">dispatch</tt>(<em>request</em>, <em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.views.generic.base.View.dispatch" title="Permalink to this definition">¶</a></dt>
<dd><p>The <tt class="docutils literal"><span class="pre">view</span></tt> part of the view &#8211; the method that accepts a <tt class="docutils literal"><span class="pre">request</span></tt>
argument plus arguments, and returns a HTTP response.</p>
<p>The default implementation will inspect the HTTP method and attempt to
delegate to a method that matches the HTTP method; a <tt class="docutils literal"><span class="pre">GET</span></tt> will be
delegated to <tt class="docutils literal"><span class="pre">get()</span></tt>, a <tt class="docutils literal"><span class="pre">POST</span></tt> to <tt class="docutils literal"><span class="pre">post()</span></tt>, and so on.</p>
<p>By default, a <tt class="docutils literal"><span class="pre">HEAD</span></tt> request will be delegated to <tt class="docutils literal"><span class="pre">get()</span></tt>.
If you need to handle <tt class="docutils literal"><span class="pre">HEAD</span></tt> requests in a different way than <tt class="docutils literal"><span class="pre">GET</span></tt>,
you can override the <tt class="docutils literal"><span class="pre">head()</span></tt> method. See
<a class="reference internal" href="../../topics/class-based-views/index.html#supporting-other-http-methods"><em>Supporting other HTTP methods</em></a> for an example.</p>
</dd></dl>

<dl class="method">
<dt id="django.views.generic.base.View.http_method_not_allowed">
<tt class="descname">http_method_not_allowed</tt>(<em>request</em>, <em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.views.generic.base.View.http_method_not_allowed" title="Permalink to this definition">¶</a></dt>
<dd><p>If the view was called with a HTTP method it doesn&#8217;t support, this
method is called instead.</p>
<p>The default implementation returns <tt class="docutils literal"><span class="pre">HttpResponseNotAllowed</span></tt> with a
list of allowed methods in plain text.</p>
</dd></dl>

<dl class="method">
<dt id="django.views.generic.base.View.options">
<tt class="descname">options</tt>(<em>request</em>, <em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.views.generic.base.View.options" title="Permalink to this definition">¶</a></dt>
<dd><p>Handles responding to requests for the OPTIONS HTTP verb.  Returns a
list of the allowed HTTP method names for the view.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="s-templateview">
<span id="templateview"></span><h2>TemplateView<a class="headerlink" href="#templateview" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="django.views.generic.base.TemplateView">
<em class="property">class </em><tt class="descclassname">django.views.generic.base.</tt><tt class="descname">TemplateView</tt><a class="headerlink" href="#django.views.generic.base.TemplateView" title="Permalink to this definition">¶</a></dt>
<dd><p>Renders a given template, with the context containing parameters captured
in the URL.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.5:</span> The context used to be populated with a <tt class="docutils literal"><span class="pre">{{</span> <span class="pre">params</span> <span class="pre">}}</span></tt> dictionary of
the parameters captured in the URL. Now those parameters are first-level
context variables.</div>
<p><strong>Ancestors (MRO)</strong></p>
<p>This view inherits methods and attributes from the following views:</p>
<ul class="simple">
<li><a class="reference internal" href="mixins-simple.html#django.views.generic.base.TemplateResponseMixin" title="django.views.generic.base.TemplateResponseMixin"><tt class="xref py py-class docutils literal"><span class="pre">django.views.generic.base.TemplateResponseMixin</span></tt></a></li>
<li><a class="reference internal" href="mixins-simple.html#django.views.generic.base.ContextMixin" title="django.views.generic.base.ContextMixin"><tt class="xref py py-class docutils literal"><span class="pre">django.views.generic.base.ContextMixin</span></tt></a></li>
<li><a class="reference internal" href="#django.views.generic.base.View" title="django.views.generic.base.View"><tt class="xref py py-class docutils literal"><span class="pre">django.views.generic.base.View</span></tt></a></li>
</ul>
<p><strong>Method Flowchart</strong></p>
<ol class="arabic simple">
<li><a class="reference internal" href="#django.views.generic.base.View.dispatch" title="django.views.generic.base.View.dispatch"><tt class="xref py py-meth docutils literal"><span class="pre">dispatch()</span></tt></a></li>
<li><a class="reference internal" href="#django.views.generic.base.View.http_method_not_allowed" title="django.views.generic.base.View.http_method_not_allowed"><tt class="xref py py-meth docutils literal"><span class="pre">http_method_not_allowed()</span></tt></a></li>
<li><a class="reference internal" href="mixins-simple.html#django.views.generic.base.ContextMixin.get_context_data" title="django.views.generic.base.ContextMixin.get_context_data"><tt class="xref py py-meth docutils literal"><span class="pre">get_context_data()</span></tt></a></li>
</ol>
<p><strong>Example views.py</strong>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.views.generic.base</span> <span class="kn">import</span> <span class="n">TemplateView</span>

<span class="kn">from</span> <span class="nn">articles.models</span> <span class="kn">import</span> <span class="n">Article</span>

<span class="k">class</span> <span class="nc">HomePageView</span><span class="p">(</span><span class="n">TemplateView</span><span class="p">):</span>

    <span class="n">template_name</span> <span class="o">=</span> <span class="s">&quot;home.html&quot;</span>

    <span class="k">def</span> <span class="nf">get_context_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">context</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">HomePageView</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_context_data</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="n">context</span><span class="p">[</span><span class="s">&#39;latest_articles&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Article</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()[:</span><span class="mi">5</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">context</span>
</pre></div>
</div>
<p><strong>Example urls.py</strong>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.conf.urls</span> <span class="kn">import</span> <span class="n">patterns</span><span class="p">,</span> <span class="n">url</span>

<span class="kn">from</span> <span class="nn">myapp.views</span> <span class="kn">import</span> <span class="n">HomePageView</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s">&#39;&#39;</span><span class="p">,</span>
    <span class="n">url</span><span class="p">(</span><span class="s">r&#39;^$&#39;</span><span class="p">,</span> <span class="n">HomePageView</span><span class="o">.</span><span class="n">as_view</span><span class="p">(),</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;home&#39;</span><span class="p">),</span>
<span class="p">)</span>
</pre></div>
</div>
<p><strong>Context</strong></p>
<ul class="simple">
<li>Populated (through <a class="reference internal" href="mixins-simple.html#django.views.generic.base.ContextMixin" title="django.views.generic.base.ContextMixin"><tt class="xref py py-class docutils literal"><span class="pre">ContextMixin</span></tt></a>) with
the keyword arguments captured from the URL pattern that served the view.</li>
</ul>
</dd></dl>

</div>
<div class="section" id="s-redirectview">
<span id="redirectview"></span><h2>RedirectView<a class="headerlink" href="#redirectview" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="django.views.generic.base.RedirectView">
<em class="property">class </em><tt class="descclassname">django.views.generic.base.</tt><tt class="descname">RedirectView</tt><a class="headerlink" href="#django.views.generic.base.RedirectView" title="Permalink to this definition">¶</a></dt>
<dd><p>Redirects to a given URL.</p>
<p>The given URL may contain dictionary-style string formatting, which will be
interpolated against the parameters captured in the URL. Because keyword
interpolation is <em>always</em> done (even if no arguments are passed in), any
<tt class="docutils literal"><span class="pre">&quot;%&quot;</span></tt> characters in the URL must be written as <tt class="docutils literal"><span class="pre">&quot;%%&quot;</span></tt> so that Python
will convert them to a single percent sign on output.</p>
<p>If the given URL is <tt class="docutils literal"><span class="pre">None</span></tt>, Django will return an <tt class="docutils literal"><span class="pre">HttpResponseGone</span></tt>
(410).</p>
<p><strong>Ancestors (MRO)</strong></p>
<p>This view inherits methods and attributes from the following view:</p>
<ul class="simple">
<li><a class="reference internal" href="#django.views.generic.base.View" title="django.views.generic.base.View"><tt class="xref py py-class docutils literal"><span class="pre">django.views.generic.base.View</span></tt></a></li>
</ul>
<p><strong>Method Flowchart</strong></p>
<ol class="arabic simple">
<li><a class="reference internal" href="#django.views.generic.base.View.dispatch" title="django.views.generic.base.View.dispatch"><tt class="xref py py-meth docutils literal"><span class="pre">dispatch()</span></tt></a></li>
<li><a class="reference internal" href="#django.views.generic.base.View.http_method_not_allowed" title="django.views.generic.base.View.http_method_not_allowed"><tt class="xref py py-meth docutils literal"><span class="pre">http_method_not_allowed()</span></tt></a></li>
<li><a class="reference internal" href="#django.views.generic.base.RedirectView.get_redirect_url" title="django.views.generic.base.RedirectView.get_redirect_url"><tt class="xref py py-meth docutils literal"><span class="pre">get_redirect_url()</span></tt></a></li>
</ol>
<p><strong>Example views.py</strong>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.core.urlresolvers</span> <span class="kn">import</span> <span class="n">reverse</span>
<span class="kn">from</span> <span class="nn">django.shortcuts</span> <span class="kn">import</span> <span class="n">get_object_or_404</span>
<span class="kn">from</span> <span class="nn">django.views.generic.base</span> <span class="kn">import</span> <span class="n">RedirectView</span>

<span class="kn">from</span> <span class="nn">articles.models</span> <span class="kn">import</span> <span class="n">Article</span>

<span class="k">class</span> <span class="nc">ArticleCounterRedirectView</span><span class="p">(</span><span class="n">RedirectView</span><span class="p">):</span>

    <span class="n">permanent</span> <span class="o">=</span> <span class="bp">False</span>
    <span class="n">query_string</span> <span class="o">=</span> <span class="bp">True</span>

    <span class="k">def</span> <span class="nf">get_redirect_url</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pk</span><span class="p">):</span>
        <span class="n">article</span> <span class="o">=</span> <span class="n">get_object_or_404</span><span class="p">(</span><span class="n">Article</span><span class="p">,</span> <span class="n">pk</span><span class="o">=</span><span class="n">pk</span><span class="p">)</span>
        <span class="n">article</span><span class="o">.</span><span class="n">update_counter</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">reverse</span><span class="p">(</span><span class="s">&#39;product_detail&#39;</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="p">(</span><span class="n">pk</span><span class="p">,))</span>
</pre></div>
</div>
<p><strong>Example urls.py</strong>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.conf.urls</span> <span class="kn">import</span> <span class="n">patterns</span><span class="p">,</span> <span class="n">url</span>
<span class="kn">from</span> <span class="nn">django.views.generic.base</span> <span class="kn">import</span> <span class="n">RedirectView</span>

<span class="kn">from</span> <span class="nn">article.views</span> <span class="kn">import</span> <span class="n">ArticleCounterRedirectView</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s">&#39;&#39;</span><span class="p">,</span>

    <span class="n">url</span><span class="p">(</span><span class="s">r&#39;^(?P&lt;pk&gt;\d+)/$&#39;</span><span class="p">,</span> <span class="n">ArticleCounterRedirectView</span><span class="o">.</span><span class="n">as_view</span><span class="p">(),</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;article-counter&#39;</span><span class="p">),</span>
    <span class="n">url</span><span class="p">(</span><span class="s">r&#39;^go-to-django/$&#39;</span><span class="p">,</span> <span class="n">RedirectView</span><span class="o">.</span><span class="n">as_view</span><span class="p">(</span><span class="n">url</span><span class="o">=</span><span class="s">&#39;http://djangoproject.com&#39;</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;go-to-django&#39;</span><span class="p">),</span>
<span class="p">)</span>
</pre></div>
</div>
<p><strong>Attributes</strong></p>
<dl class="attribute">
<dt id="django.views.generic.base.RedirectView.url">
<tt class="descname">url</tt><a class="headerlink" href="#django.views.generic.base.RedirectView.url" title="Permalink to this definition">¶</a></dt>
<dd><p>The URL to redirect to, as a string. Or <tt class="docutils literal"><span class="pre">None</span></tt> to raise a 410 (Gone)
HTTP error.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.views.generic.base.RedirectView.permanent">
<tt class="descname">permanent</tt><a class="headerlink" href="#django.views.generic.base.RedirectView.permanent" title="Permalink to this definition">¶</a></dt>
<dd><p>Whether the redirect should be permanent. The only difference here is
the HTTP status code returned. If <tt class="docutils literal"><span class="pre">True</span></tt>, then the redirect will use
status code 301. If <tt class="docutils literal"><span class="pre">False</span></tt>, then the redirect will use status code
302. By default, <tt class="docutils literal"><span class="pre">permanent</span></tt> is <tt class="docutils literal"><span class="pre">True</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.views.generic.base.RedirectView.query_string">
<tt class="descname">query_string</tt><a class="headerlink" href="#django.views.generic.base.RedirectView.query_string" title="Permalink to this definition">¶</a></dt>
<dd><p>Whether to pass along the GET query string to the new location. If
<tt class="docutils literal"><span class="pre">True</span></tt>, then the query string is appended to the URL. If <tt class="docutils literal"><span class="pre">False</span></tt>,
then the query string is discarded. By default, <tt class="docutils literal"><span class="pre">query_string</span></tt> is
<tt class="docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<p><strong>Methods</strong></p>
<dl class="method">
<dt id="django.views.generic.base.RedirectView.get_redirect_url">
<tt class="descname">get_redirect_url</tt>(<em>**kwargs</em>)<a class="headerlink" href="#django.views.generic.base.RedirectView.get_redirect_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Constructs the target URL for redirection.</p>
<p>The default implementation uses <a class="reference internal" href="#django.views.generic.base.RedirectView.url" title="django.views.generic.base.RedirectView.url"><tt class="xref py py-attr docutils literal"><span class="pre">url</span></tt></a> as a starting
string, performs expansion of <tt class="docutils literal"><span class="pre">%</span></tt> parameters in that string, as well
as the appending of query string if requested by <a class="reference internal" href="#django.views.generic.base.RedirectView.query_string" title="django.views.generic.base.RedirectView.query_string"><tt class="xref py py-attr docutils literal"><span class="pre">query_string</span></tt></a>.
Subclasses may implement any behavior they wish, as long as the method
returns a redirect-ready URL string.</p>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>         
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Base views</a><ul>
<li><a class="reference internal" href="#view">View</a></li>
<li><a class="reference internal" href="#templateview">TemplateView</a></li>
<li><a class="reference internal" href="#redirectview">RedirectView</a></li>
</ul>
</li>
</ul>

  <h3>Browse</h3>
  <ul>
    
      <li>Prev: <a href="index.html">Class-based views</a></li>
    
    
      <li>Next: <a href="generic-display.html">Generic display views</a></li>
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../../index.html">Django 1.5.9 documentation</a>
        
          <ul><li><a href="../index.html">API Reference</a>
        
          <ul><li><a href="index.html">Class-based views</a>
        
        <ul><li>Base views</li></ul>
        </li></ul></li></ul>
      </li>
  </ul>  

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../../_sources/ref/class-based-views/base.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Mar 19, 2015</p>
          </div> 
        
      
    </div>
    
    <div id="ft">
      <div class="nav">
    &laquo; <a href="index.html" title="Class-based views">previous</a> 
     |
    <a href="../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="generic-display.html" title="Generic display views">next</a> &raquo;</div>
    </div>
  </div>

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