Ticket #2966: direct_to_template-extra_context.patch

File direct_to_template-extra_context.patch, 867 bytes (added by wam-djangobug@…, 18 years ago)

patch to add extra_context param to direct_to_template() generic view

  • simple.py

     
    22from django.template import RequestContext
    33from django.http import HttpResponse, HttpResponsePermanentRedirect, HttpResponseGone
    44
    5 def direct_to_template(request, template, **kwargs):
     5def direct_to_template(request, template, extra_context=None, **kwargs):
    66    """
    77    Render a given template with any extra URL parameters in the context as
    88    ``{{ params }}``.
    99    """
    10     return render_to_response(template, {'params' : kwargs}, context_instance=RequestContext(request))
     10    if extra_context is None: extra_context = {}
     11    return render_to_response(template, dict(extra_context, params=kwargs), context_instance=RequestContext(request))
    1112
    1213def redirect_to(request, url, **kwargs):
    1314    """
Back to Top