从一个窗体中的多个下拉列表中获取文章

2024-04-18 17:39:21 发布

您现在位置:Python中文网/ 问答频道 /正文

有一个表单,用户可以在其中更改attribute name上的名称,并更改attribute a连接到哪个attribute(attribute b)。你知道吗

模板:

"<form id="form1" name="form1" method="post" action="/define_a/{{c.id}}/edit/">
{% csrf_token %}
{% endblock %}

{% block buttons %}
<p><input type="submit" value="Save" />&nbsp;<a href="/define_a/{{c.id}}/">Cancel</a>
</p>
{% endblock %}

{% block a_rows %}
{% for a, a_form in a_list %}
<tr><td><img class="icon" src="{{images_dir}}/delete-icon.png" 
onclick="javascript: return confirmDelete_name('Are you sure? 
This will delete the stuff and all associated information. 
The removal happens immediately and cannot be undone.', '{{a.id}}', 'delete');" />
</td><td>{{a_form.name}}</td>
<td>
<select name= "test">
<option value = "Null">None</option>
<option value = "{{a_form.id}}" selected>{{a.b}}</option>
{% for a, a_form in a_list %}
<option value = "{{a_form.id}}">{{a.name}}</option>
{% endfor %}"

查看:

检查它是一个职位,它是有效的。你知道吗

 post = [myForm(request.POST, instance = test) for a in a's];
                for p in post :
                    if not new_t.b == p:
                        if p == 'None':
                        new_t.b = None;
                    else:
                       new_t.b = p;

但是我不能从帖子的下拉列表中得到所有的值。 我从下拉列表中得到了所有的a.name,但只有一个值,有时我根本没有得到任何值。你知道吗

有什么想法吗?你知道吗


Tags: nameinformnoneidnewforvalue