2014-03-31 25 views
0

我在Django中的{% csrf_token %}模板標記有問題。在通過get加載的頁面上很好,但是如果我使用post加載頁面,則標籤不會加載到頁面請求的頁面上。csrf_token未在通過郵件加載的頁面上創建

我使用render_to_response渲染

任何想法的頁?從POST請求調用render_to_response當與CSRF令牌

感謝

回答

1

你更新你的背景?像這樣:

from django.core.context_processors import csrf 
from django.shortcuts import render_to_response 

def my_view(request): 
    if request.method == 'POST': 
     c = {} 
     c.update(csrf(request)) 
     return render_to_response("a_template.html", c) 
    else: 
     # GET code... 
+0

不,但現在我是:)謝謝 – icebox3d