This is not possible, since your function is currently written for you, but for the same behavior you can do something like the following:
from django.shortcuts import render def decorator(view): def wrapper(request, *args, **kwargs): context = {'foo': 'bar'} args = args + (context,) return view(request, *args, **kwargs) return wrapper @decorator def index(request, *args): return render(request, 'index.html', *args)
This will force the decorator to add your context dictionary to the end of the positional arguments, which are passed to index() , which are then passed to render() .
source share