- Language: en
- Documentation version: 2.0
3. How to order on two fields¶
order_by on querysets can take one or more attribute names, allowing you to order on two or more fields.
In : from django.contrib.auth.models import User
In : User.objects.all().order_by(“is_active”, “-last_login”, “first_name”) Out: <QuerySet [<User: Guido>, <User: shabda>, <User: Tim>]>