Django问题:只想显示一个数字
您好,我在 Django 中有一组数字,定义为:
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').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))
在我的服务订单视图中,我有一个模板。在此模板中,它显示订单号列表。
{%for order in orders%}
{{order.pk}}
{%endfor%}
这很好,但我只想显示一个订单号。它可以是该列表中的任何数字。
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').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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将顺序限制为视图或模板中的一个对象。
在视图中:
在模板中:
但是是的,shezzy,你的问题很混乱:)
Either limit the order to one object in the view, or in the template.
In the view:
In the template:
But yeah shezzy, your question is confusing :)