By Sean Reifschneider Date 2010-02-02 21:04 Tags django, python, sean reifschneider
I just posted a Django snippet that (ab)uses a decorator to change how you call templates in Dango views. For example, it makes my view code something like this:
####################################
@with_template('friends/index.html')
def friends(request, context, username):
context['user'] = User.objects.get(username = username)
And the view:
{% extends "base.html" %}
{% block content %}
<h1>{{ user.username }}'s Friends</h1>
comments powered by Disqus