[Fixed]-CSRF verification failure for single form with two models

1👍

Use the render shortcut instead of render_to_response. This ensures that the template is rendered with the request, which allows the csrf_token tag to work.

from django.shortcuts import render

def foo_add(request):
    ...
    return render(
        request,
        'foo_app/foo_add.html', 
        {'foo_form': fooForm, 'bar_form': barForm},
    )

Leave a comment