title: How do I use multiple style sheets in Django, where the style sheet is determined by a GET variable, without violating DRY?
body: <p>I an writing a website that will have multiple skins. Each skin has its own style sheet. I would like the skin used to be determined by a GET variable, so that this URL:</p>
  
  <pre><code>whatever?skin=foo
  </code></pre>
  
  <p>will cause the page to be rendered containing this HTML in the header: </p>
  
  <pre><code>&lt;link rel="stylesheet" type="text/css" href="/site_media/foo.css"/&gt;
  </code></pre>
  
  <p>(Normally I want the skin to be determined by a user's preference, but I want this way of doing it as well, so a user can preview what a new skin will look like, as well as for making it easy for me while developing it.)</p>
  
  <p>This is fairly easy to do in Django, for example you could use a template with this line:</p>
  
  <pre><code>&lt;link rel="stylesheet" type="text/css" href="/site_media/{{skin}}.css"/&gt;
  </code></pre>
  
  <p>And a view like this:</p>
  
  <pre><code>def whateverView(request):
      """ called by URL /whatever """
      skin = request.GET.get('skin', "default")
      c = RequestContext(request, {'skin': skin})
      html = whateverTemplate.render(c)
      return HttpResponse(html)
  </code></pre>
  
  <p>But I don't want to have to do it like that, as I would have to add the same code to every single view, which would violate <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself" rel="nofollow">DRY</a>. </p>
  
  <p>So is there some way I can do it, such that it works on all my pages, while only writing the code once?</p>