Django question: Want to display only one number
Hello I have a set of numbers in Django Defined as:
def order_list_service(request, type_id = 1):
orders = models.Order.objects.filter(is_hot = False, is_storage = False, orderservicelist__service__type = type_id).order_by('pk').开发者_JAVA百科distinct()
request.session['orders']= orders
def service_order(request, client_id = 0, request_type = 1):
orders = request.session['orders']
return render_to_response('service_step1.html', {'orders':orders }, context_instance = RequestContext(request))
In my service order view I have a template. In this template It display the list of order numbers.
{%for order in orders%}
{{order.pk}}
{%endfor%}
This is good However I just want to display just one order number. It could be any number from that list.
Either limit the order to one object in the view, or in the template.
In the view:
order = orders[0], orders.get(id=3), etc.
return render_to_response('service_step1.html', {'orders':order }, context_instance = RequestContext(request))
In the template:
{{ orders.0.id }}
{{ orders.5.id }}
But yeah shezzy, your question is confusing :)
精彩评论