0

有一个表单,用户可以在其中更改属性名称上的名称并更改连接到哪个属性 a(属性 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 但只有一个值,有时我根本没有得到任何值。

有任何想法吗?

4

0 回答 0