Brandon Smith Brandon Smith - 2 months ago 14x
Python Question

Confusion about django.shortcuts.render() method signature in 1.10

The Django 1.10 release notes ( say:

  • The dictionary and context_instance parameters for the following functions are removed:

    • django.shortcuts.render()

    • ...

However, the documentation for
in 1.10 ( still lists
as an argument of type


A dictionary of values to add to the template context. By default, this is an empty dictionary. If a value in the dictionary is callable, the view will call it just before rendering the template.

My question, to put it frankly, is what gives? Normally this would be an academic question, but the following code:

def index(request):
context = RequestContext(request, {})
return render(request, 'maintenance/maintenance.html', context)

yields this error:

TypeError: dict expected at most 1 arguments, got 3

and this was the best lead I could find as to what the problem might be. I should also mention that this error appeared after updating Django from 1.8 to 1.10.


You are confusing context and context_instance, which are two separate arguments. The context_instance argument has been removed in Django 1.10, but context remains.

As the docs say, context should be a dictionary of values. You are getting the error because you are passing a RequestContext instance instead of a dictionary. You can fix your example view by changing it to:

def index(request):
    context = {}
    return render(request, 'maintenance/maintenance.html', context)