다른 체크 박스 질문의 목록의 하위 집합 만 확인합니다. 목록에 항목이 있습니다. 각 항목에는 확인란이 있습니다. 내가하고 싶은 것은 아이템의 하위 집합 인 모든 항목을 체크하는 것입니다. items = client.storageitem_set.all()
의 부분 집합이는 edit_order라는 또 다른 관점에서 정의 items = models.StorageItem.objects.filter(orderstoragelist__order__pk = order.pk)
입니다. 장고 체크 박스 항목
M
당신은 몇 가지 모델을 가지고 가정, 전에 이런 짓을 적이 있지만이 도움이 될 수
def client_items(request, client_id = 0):
client = None
items = None
try:
client = models.Client.objects.get(pk = client_id)
items = client.storageitem_set.all()
except:
return HttpResponse(reverse(return_clients))
return render_to_response('items.html', {'items':items, 'client':client}, context_instance = RequestContext(request)) # Redirect after POST
{% for item in items %}
<tr class="items_table_row">
<td><input type="checkbox" name="{{item.pk}}" value="{{item.pk}}" "{% ifequal forloop.counter 1 %} checked="checked"{% endifequal %}>
<td>{{item.tiptop_id}}</td><td>{{item.alternative_id}}</td><td>{{item.title}}</td><td>{{item.type}}</td><td>{{item.format}}</td>
<td><span id="{{item.pk}}" name="type">{{item.itemstatushistory_set.latest}}</span></td><td>{{item.itemstatushistory_set.latest.date.date|date:"d M Y"}}</td>
<td><a href="{% url tiptop.views.edit_item item.client.pk item.pk %}" onclick="return showAddAnotherPopup(this);">Edit</a></td>
</tr>
{% endfor %}
당신은 어떻게 다른보기에서 목록을 가져올 기대? *이 *보기에 어떻게 도달합니까? –
@ 대니얼, 기본적으로 views.edit_order에는 모든 항목이 아닌 항목 목록이 있습니다. 그냥 주문한 것 뿐이야. 따라서 각 view.edit 주문에는 항목 목록 페이지로 리디렉션되는 버튼이 있습니다. 모든 항목이 나열됩니다. views.edit_order에 나열된 모든 항목을 전체 항목 목록에서 확인하려고합니다. 다른 항목은 unticked해야합니다. – Shehzad009
내가 당신이라면 장고 양식으로이 작업을 시도한 다음 해당 양식에 적절한 초기 사전을 작성하려고했을 것입니다. –