djangosnippets.org: Latest snippets posted by rmthttp://djangosnippets.org/users/rmt/2009-06-22T04:58:42.640407-05:00rmtDjango Class Views
2009-06-22T04:58:42.640407-05:00rmthttp://djangosnippets.org/snippets/1584/<p>After using Zope3/Grok for a little, I wondered how hard it would be to implement views as classes in Django, in a similar vain to how it's done in Grok. I came up with something rather simple but effective. It may be more appropriate if you use a template engine …</p>
Freely redistributableServe multiple hostnames with different URLCONF's from one Django instance
2009-05-17T05:42:32.635660-05:00rmthttp://djangosnippets.org/snippets/1509/<p>This works with <code>Django 1.0.0</code> and later. It sets the <code>request.urlconf</code> variable to an alternate urlconf, if there's a match to the hostname in <code>settings.MULTIHOST_URLCONF_MAP</code></p>
Freely redistributableLanguage aware template loader
2009-04-07T07:18:09.087780-05:00rmthttp://djangosnippets.org/snippets/1416/<p>If you try to load a template named filename.LANG.html it will try to load filename.de.html first, then filename.html afterwards (assuming that German is the currently selected language).</p>
<p>Usage: Put in a file named langtemplateloader.py under your project, and replace django's default filesystem loader with this in the TEMPLATE_LOADERS section of …</p>
Freely redistributableUsing Django Generics with Jinja2
2008-12-10T04:10:18.744030-06:00rmthttp://djangosnippets.org/snippets/1241/<p>Jinja2, while a great replacement for Django templates, is not a drop-in replacement for it. I wanted to use Photologue with my Jinja templates, but because Photologue uses Django generics, so I decided to see if I could use Jinja2 with generics, and then only modify the templates. It was …</p>
Freely redistributableMako support as decorator
2007-11-07T01:05:20.491824-06:00rmthttp://djangosnippets.org/snippets/459/<p>This snippet allows you to use @mako("templatename.mako") to define a mako template to use.</p>
<p>Your python method just has to return a dictionary that will be passed to mako's context, after the addition of the "request" variable to the dictionary. If you return a non-False non dictionary object, it will …</p>
Freely redistributable