[Django]-CSRF Verification Failed โ€“ Django

3๐Ÿ‘

โœ…

If you use render_to_response, you must provide a RequestContext to make the CSRF token work.

return render_to_response('rango/search.html',
                          {'result_list':result_list},
                          context_instance=RequestContext(request))

However the easier solution, as used by Django 1.7 version of your tutorial, is to use the render shortcut instead of render_to_response.

from django.shortcuts import render

render(request, 'rango/search.html', {'result_list':result_list})

As an aside, you have a missing % in action="{ url 'search' %}">.

๐Ÿ‘คAlasdair

Leave a comment