Sorting Strategies for Optional Fields in Django
February 03, 2026
Introduction
You're building an admin dashboard that displays users sorted by their most recent login. The goal is simple: identify your most engaged users to prioritize them for a new beta feature access.
You sort by last_login in descending order, expecting to see users who just logged in at the top. Instead, every user who has never logged in appears first, pushing your active users (the ones you actually care about) off the first page.