2024-05-07 05:31:11 发布
网友
所以我想做标题上说的,我不知道怎么做,因为我是新来的。你知道吗
<p>{{ form.description }}</p>
这就是我在列表中使用
{% for form in forms %}
但我想展示一个特定物体的描述。你知道吗
提前谢谢。你知道吗
<form method="post" novalidate>{% csrf_token %} {{ form.non_field_errors }} {% for hidden_field in form.hidden_fields %} {{ hidden_field.errors }} {{ hidden_field }} {% endfor %} <table border="1"> {% for field in form.visible_fields %} <tr> <th>{{ field.label_tag }}</th> <td> {{ field.errors }} {{ field }} {{ field.help_text }} </td> </tr> {% endfor %}
看这篇文章:[link][1]https://simpleisbetterthancomplex.com/article/2017/08/19/how-to-render-django-form-manually.html
通常django模板将用django视图中呈现的数据作为字典填充,这些数据可以在使用django模板标记“{tag\u name}}”的模板中调用
在这里,您将把所有表单呈现为字典中的一个列表,这样就可以通过循环显示每个表单。你知道吗
{% for form in forms %} {{form.description}} {% endfor %}
这样,就可以显示每个窗体的数据。如果只想显示特定窗体的数据,则正确的方法是使用特定窗体的数据呈现视图,并使用template标记在template中显示数据{{表格.说明}}你知道吗
查看django文档:https://docs.djangoproject.com/en/2.1/topics/templates/
看这篇文章:[link][1]https://simpleisbetterthancomplex.com/article/2017/08/19/how-to-render-django-form-manually.html
通常django模板将用django视图中呈现的数据作为字典填充,这些数据可以在使用django模板标记“{tag\u name}}”的模板中调用
在这里,您将把所有表单呈现为字典中的一个列表,这样就可以通过循环显示每个表单。你知道吗
这样,就可以显示每个窗体的数据。如果只想显示特定窗体的数据,则正确的方法是使用特定窗体的数据呈现视图,并使用template标记在template中显示数据{{表格.说明}}你知道吗
查看django文档:https://docs.djangoproject.com/en/2.1/topics/templates/
相关问题 更多 >
编程相关推荐