Skip to content

Instantly share code, notes, and snippets.

@jdelafon
Last active February 3, 2016 11:55
Show Gist options
  • Save jdelafon/63be77925b32e1f9927c to your computer and use it in GitHub Desktop.
Save jdelafon/63be77925b32e1f9927c to your computer and use it in GitHub Desktop.
Django order by NULLs last
qs = qs.extra(
select={'key_is_null': sort_key+' IS NULL'},
order_by = ['-key_is_null', sort_key]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment