Skip to content
Justice Tech School

Ordering and Slicing

order_by sorts and slices limit.

Example
Post.objects.order_by("-created")[:5]
Post.objects.order_by("title", "-views")

Exercise

Newest first.

order_by("created")

Quiz Test

What does a minus sign mean?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.