Jonny B Jonny B - 1 year ago 248
Python Question

Django 1.10 RequestContext processors not working

After updating to django 1.10, processors stop working.

This menu context for many views:

def menu_category(request):
category_parent = Category.objects.filter(parent__isnull=True, is_active=True).order_by('mass')
category_child = Category.objects.filter(parent__isnull=False, is_active=True).order_by('mass')
return {'category_parent': category_parent, 'category_child': category_child}

This view for django 1.9 (in django 1.10 processors=[menu_category] empty context):

def news_main(request):
posts = Post.objects.filter(
Q( | Q(date_completion=None),,
return render_to_response('news/news_main.html',
{'posts': posts},
RequestContext(request, processors=[menu_category]))

Answer Source

You should never have been passing a RequestContext to render_to_response, and Django 1.10 has made that an error. Instead use the render shortcut:

return render(request, 'news/news_main.html', {'posts': posts})

Note that whenever you upgrade a version you should always make sure to read the release notes; in this case the change is noted under Features removed in 1.10.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download