djangoで可変フォームを作成しようとしていますが、 が正しく動作していないようです。フォーム値の代わりにトークンを表示してくれることを願っています。Django Python、フォームにcsrfトークンが表示されます
私を助けてください!
url。
url(r'^test', views.test),
ビューです。
def test(request):
if request.method == "POST":
for key, value in request.POST.items():
response = '%s %s' % (key, value)
return HttpResponse(response)
return render(request, 'datos2.html')
datos2。
<form action="/test" method="post"> {% csrf_token %}
<input type="text" name="eee">
<input type="submit">
</form>
<p>ADD VALUE</p>
<button onclick="myFunction()">ADD</button>
<script>
function myFunction() {
var x = document.createElement("INPUT");
x.setAttribute("type", "text");
x.setAttribute("value", "0");
x.setAttribute("name", "eee");
document.body.appendChild(x);
}
</script>
私を助けてください!