在 Django 中传递参数以形成动作?
Template:
<form method="post" action="/reply/{{feed.id}}/">
{{rform.as_p}}
<input type="submit" value="send" />
</form>
和 url:
(r'^reply/(\d+)/$',reply),
但是当我们提交表单时,{{feed.id}}
没有被翻译,url 指向 /reply//
表单中不允许使用参数行动?
如果允许的话为什么它在这里不起作用?
谢谢
Template:
<form method="post" action="/reply/{{feed.id}}/">
{{rform.as_p}}
<input type="submit" value="send" />
</form>
and url:
(r'^reply/(\d+)/
But when we submit the form, {{feed.id}}
is not translated and url directs to /reply//
Are parameters not allowed in form actions?
If its allowed then why is it not working here?
Thanks
,reply),
But when we submit the form, {{feed.id}}
is not translated and url directs to /reply//
Are parameters not allowed in form actions?
If its allowed then why is it not working here?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果
{{ feed.id }}
为空,则意味着feed.id
为空,或者feed
为 None。使用render_to_response
渲染模板时,请确保在视图上下文中传递feed
If
{{ feed.id }}
is empty it means that that eitherfeed.id
is empty, orfeed
is None. Make sure you are passingfeed
in your view context when you render the template usingrender_to_response
我假设你的提要是字典对象?
在您的
views.py
模块中I assume your feed is dictionary object?
In your
views.py
module