I have a datetime field, which can be zero and id, how to do qs.order_by ('field__isnull', 'name'), but this leads to:
Join on field 'field' not permitted. Did you misspell 'isnull' for the lookup type?
Is this even possible?
there may be better ways, but one possibility is to annotate your request:
from django.db.models import Count qs.annotate(null_count=Count('field_name')).order_by('null_count')
I hope your model looks something like this:
date_deleted = models.DateTimeField(blank=True, null=True)
If True then you can do this:
qs.order_by('-date_deleted')