#process a dict and remove by default the 'request' key
cleandict = lambda dlist, ignore = 'request' : dict((key, val) for key, val in dlist.items() if key not in ignore)
from django.shortcuts import render_to_response
#render the template - assume a html format
def render_template(func):
'''ensure the view using this has the template name matching it'''
def render(*args, **kwargs):
variables = func(*args, **kwargs)
return render_to_response(func.__name__ + '.html', cleandict(variables))
return render
Example code:
@render_template
def myview(request):
variables = {'Hello': 'World', 'Monty' : 'Python'}
return locals()
Comments
your cleandict needs a patch:
either:
or:
will fix the problem...
#