render_with decorator

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from django.shortcuts import render_to_response
from django.template import RequestContext

def render_with(template):
    def render_with_decorator(view_func):
        def wrapper(*args, **kwargs):
            request = args[0]
            context = view_func(*args, **kwargs)
            return render_to_response(
                template, 
                context, 
                context_instance=RequestContext(request),
            )
        return wrapper
    return render_with_decorator

More like this

  1. render_to by asolovyov 5 years, 10 months ago
  2. simplified render_to_response with RequestContext by jasongreen 4 years, 3 months ago
  3. Render (with RequestContext) by alcides 5 years, 8 months ago
  4. Auto rendering decorator with options by Batiste 6 years, 3 months ago
  5. DRY template rendering decorator update by jakecr 4 years, 1 month ago

Comments

(Forgotten your password?)