Django : CSRF verification failed even after adding {% csrf_token %}

后端 未结 7 1262
轻奢々
轻奢々 2021-01-03 11:20

views.py:

def index(request):
    return render_to_response(\'index.html\', {})

def photos(request, artist):
    if not artist:
        r         


        
相关标签:
7条回答
  • 2021-01-03 11:57

    This worked for me:

    {% csrf_token %} In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL.

    In views.py:

    from django.template import RequestContext

    ...

    ...

    ...

    return render_to_response("home.html", {}, context_instance=RequestContext(request))

    0 讨论(0)
提交回复
热议问题