View decorator to automate templates.
Place the above code in your view, and then you can use it to specify what template to use. Set elements of the context as a dictionary and that gets passed to the template as well. For example: In view.py: #################################### @with_template('friends/index.html') def friends(request, context, username): context['user'] = User.objects.get(username = username) in friends/index.html: {% extends "base.html" %} {% block content %} <h1>{{ user.username }}'s Friends</h1>
- template
- view
- decorator