【发布时间】:2010-03-25 13:36:56
【问题描述】:
我想在博客应用程序中使用django.contrib.comments 并自定义表单的显示方式。我的问题是,尽管显示隐藏字段效果很好,但我无法显示字段。我查看了文档并将其与显示表单的常规方式进行了比较,但老实说,我不知道为什么以下内容不起作用:
{% get_comment_form for comments_object as form %}
<form action="{% comment_form_target %}" method="POST">
[…]
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% for field in form.fields %}
{{field}}
{% endfor %}
[…]
</form>
输出如下:
<form action="/comments/post/" method="POST">
<input type="hidden" name="content_type" value="flatpages.flatpage" id="id_content_type" />
<input type="hidden" name="object_pk" value="1" id="id_object_pk" />
<input type="hidden" name="timestamp" value="1269522506" id="id_timestamp" />
<input type="hidden" name="security_hash" value="ec4…0fd" id="id_security_hash" />
content_type
object_pk
timestamp
security_hash
name
email
url
comment
honeypot
[…]
</form>
</div>
你能告诉我我做错了什么吗?提前致谢
【问题讨论】:
标签: django templates django-comments