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 表单中有一个<select>字段,我想做的是<option>根据selected项目是否具有特定值来设置。该值作为GET变量传递并包含页面的 id。我怎样才能做到if value == <GET variable>: set option tag to selected?
<select>
<option>
selected
GET
if value == <GET variable>: set option tag to selected
如果它是一个表单,那么将常规初始字典传递给表单就足够了:
在 Django forms.ChoiceField 上设置选定的值