also sort purchases by created_at
Django CI/CD / test (push) Successful in 59s Details
Django CI/CD / build-and-push (push) Successful in 2m24s Details

This commit is contained in:
Lukáš Kucharczyk 2024-10-18 09:50:10 +02:00
parent f8d621e710
commit d9290373b0
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 1 additions and 1 deletions

View File

@ -26,7 +26,7 @@ def list_purchases(request: HttpRequest) -> HttpResponse:
context: dict[Any, Any] = {}
page_number = request.GET.get("page", 1)
limit = request.GET.get("limit", 10)
purchases = Purchase.objects.order_by("-date_purchased")
purchases = Purchase.objects.order_by("-date_purchased", "-created_at")
page_obj = None
if int(limit) != 0:
paginator = Paginator(purchases, limit)