Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 django 表单,其值已初始化。但我不希望将值显示给用户。我在模板中使用 {{formobject.fieldname}} 但它也显示值。是否有任何选项可以隐藏该字段单看价值?
在您的视图中初始化第二个未绑定的表单,
blank_form = MyForm()
然后使用此表单在模板中呈现您的空白字段。
{{ blank_form.fieldname }}