篇首语:本文由小常识网(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