Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 6924972363177ee2ba37e2f37b22c4a6 > files > 90

django-staticfiles-0.3.2-3.fc14.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>Helpers &mdash; django-staticfiles v0.3.1 documentation</title>
    <link rel="stylesheet" href="_static/nature.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.3.1',
        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-staticfiles v0.3.1 documentation" href="index.html" />
    <link rel="next" title="Settings" href="settings.html" />
    <link rel="prev" title="Management Commands" href="commands.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="settings.html" title="Settings"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="commands.html" title="Management Commands"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">django-staticfiles v0.3.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="helpers">
<h1>Helpers<a class="headerlink" href="#helpers" title="Permalink to this headline">¶</a></h1>
<div class="section" id="static-url-context-processor">
<h2><tt class="docutils literal"><span class="pre">static_url</span></tt> context processor<a class="headerlink" href="#static-url-context-processor" title="Permalink to this headline">¶</a></h2>
<p>To refer to static file assets from a template, ensure you have set the
<a class="reference internal" href="settings.html#static-url"><em>STATIC_URL</em></a> setting to the URL path where the static files are served.</p>
<p>Next, add the <tt class="docutils literal"><span class="pre">static_url</span></tt> context processor to your
<tt class="docutils literal"><span class="pre">TEMPLATE_CONTEXT_PROCESSORS</span></tt> setting:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">TEMPLATE_CONTEXT_PROCESSORS</span> <span class="o">=</span> <span class="p">(</span>
    <span class="s">&#39;staticfiles.context_processors.static_url&#39;</span><span class="p">,</span>
<span class="p">)</span>
</pre></div>
</div>
<p>Templates rendered with <tt class="docutils literal"><span class="pre">RequestContext</span></tt> will now have access to a
<a class="reference internal" href="settings.html#static-url"><em>STATIC_URL</em></a> context variable:</p>
<div class="highlight-python"><pre>&lt;link href="{{ STATIC_URL }}css/polls.css" rel="stylesheet" type="text/css" /&gt;</pre>
</div>
</div>
<div class="section" id="serving-static-files-during-development">
<h2>Serving static files during development<a class="headerlink" href="#serving-static-files-during-development" title="Permalink to this headline">¶</a></h2>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Don&#8217;t use this on production servers.
This feature is <strong>only intended for development</strong>.
Please, don&#8217;t shoot yourself in the foot. Thanks.</p>
</div>
<p>To serve static media for both <tt class="docutils literal"><span class="pre">MEDIA_URL</span></tt> and <a class="reference internal" href="settings.html#static-url"><em>STATIC_URL</em></a> add the
following snippet to the end of your primary URL configuration:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.conf</span> <span class="kn">import</span> <span class="n">settings</span>
<span class="kn">from</span> <span class="nn">staticfiles.urls</span> <span class="kn">import</span> <span class="n">staticfiles_urlpatterns</span>

<span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">:</span>
    <span class="n">urlpatterns</span> <span class="o">+=</span> <span class="n">staticfiles_urlpatterns</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Helpers</a><ul>
<li><a class="reference internal" href="#static-url-context-processor"><tt class="docutils literal"><span class="pre">static_url</span></tt> context processor</a></li>
<li><a class="reference internal" href="#serving-static-files-during-development">Serving static files during development</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="commands.html"
                        title="previous chapter">Management Commands</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="settings.html"
                        title="next chapter">Settings</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/helpers.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" size="18" />
      <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>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="settings.html" title="Settings"
             >next</a> |</li>
        <li class="right" >
          <a href="commands.html" title="Management Commands"
             >previous</a> |</li>
        <li><a href="index.html">django-staticfiles v0.3.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2010, Jannis Leidel.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.2.
    </div>
  </body>
</html>