I have this URL in my project:
url(r'^alerts/inbox/$', 'inbox', {'template_name': 'inbox.xhtml' }, name = 'inbox'),
The inbox view is exactly this:
@login_required()
@ownsBid
def inbox(request, template_name):
return render_to_response(template_name, context_instance=RequestContext(request))
My ownsBid decorator is:
def ownsBid(fn):
def _check(request, *args, **kwargs):
return fn(request, kwargs)
return _check
When I use:
fn(request, kwargs)
I get a TemplateDoesNotExist at /alerts/inbox/. If I do instead:
fn(request, kwargs['template_name'])
It renders the template without problems. I don't have a clue why this happens. But if I have to pass a specific parameter to the view, it totally breaks DRY principle of decorators.