1 2 3 4 5 6 7 8 | from django.shortcuts import render_to_response
from django.utils.datastructures import MultiValueDict
def direct_to_template(request, template, **kwargs):
params = MultiValueDict()
params.update(kwargs)
params.update(request.GET)
return render_to_response(template % kwargs, params)
|
More like this
- direct to template from a subdir by Scanner 4 years, 7 months ago
- Limit queryset to objects related to parent in ManyToMany fields within admin inlines by DrMeers 2 years, 11 months ago
- Handy tag for generating URLs to media files by Amr Mostafa 6 years, 1 month ago
- Allow any view (probably a generic view) to accept POST variables into extra_context by orblivion 2 years, 6 months ago
- Django 1.2+ template loader for Jinja2 by SimonSapin 2 years, 11 months ago
Comments
Pretty neat!
Unless you need to pass the template name to your context, you could also just do:
#