python - I how can I return objects in Django? -
the following
model.objects.all()[:10]
will return 10 records ordered primary key. i'm trying objects in reverse order. in other words if highest primary key 5000, i'm trying 5000, 4999, 4998...
i have tried:
model.objects.reverse().all()[:10]
but not appear affect order
you can do:
model.objects.order_by('-id')[:10]
Comments
Post a Comment