[英]Passing parameters to form action in Django?
模板:
<form method="post" action="/reply/{{feed.id}}/">
{{rform.as_p}}
<input type="submit" value="send" />
</form>
和網址:
(r'^reply/(\d+)/$',reply),
但是,當我們提交表單時, {{feed.id}}
不會被翻譯,並且網址會直接指向/reply//
表單操作中是否不允許使用參數?
如果允許,那么為什么在這里不起作用?
謝謝
如果{{ feed.id }}
為空,則意味着feed.id
為空,或者feed
為None。 使用render_to_response
渲染模板時,請確保在視圖上下文中傳遞feed
我認為您的供稿是字典對象?
在您的views.py
模塊中
from django.shortcuts import render_to_response;
def myforms(request):
feed = {"id":"369"}
return render_to_response('html-template/blank.html', {'feed': feed})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.