python Cosa loca de Django

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Cosa loca de Django相关的知识,希望对你有一定的参考价值。

In [1]: ii = InvoiceItem.objects.all()[:2]

In [2]: i = Invoice.objects.all()[:2]

In [3]: i.first().id, i.last().id
Out[3]: (23, 17)

In [4]: i.values_list('id', flat=True)
Out[4]: [23, 22]

In [5]: i.first().id, i.last().id
Out[5]: (23, 17)

In [6]: i
Out[6]: [<Invoice: 7>, <Invoice: 6>]

In [7]: i[0].id, i[1].id
Out[7]: (23, 22)

In [8]:  Invoice.objects.all().last()
Out[8]: <Invoice: 1>

In [9]:  Invoice.objects.all().last().id
Out[9]: 17

In [10]: type(Invoice.objects.all()[:2])
Out[10]: django.db.models.query.QuerySet

In [11]: type(Invoice.objects.all())
Out[11]: django.db.models.query.QuerySet
invoice_6_contract_5_items = invoice_6.invoice_items.filter(
   contract=self.contract5
)
print invoice_6_contract_5_items.first().id, invoice_6_contract_5_items.last().id
print invoice_6_contract_5_items[0].id, invoice_6_contract_5_items[1].id

output >>

22 22
22 23

以上是关于python Cosa loca de Django的主要内容,如果未能解决你的问题,请参考以下文章

基于 CentOS-Stream9 构建官方CoreOS COSA 镜像并构建 CoreOS

基于 CentOS-Stream9 构建官方CoreOS COSA 镜像并构建 CoreOS

css Cosa前端消息来源

计算机毕业设计Python+djang的小区疫情防控系统(源码+系统+mysql数据库+Lw文档)

JavaScript Efecto悬停sobre cualquier cosa 1

JavaScript Efecto HOVER sobre cualquier cosa