I have a queryset in my Django application:
databytes_all = DataByte.objects
Each item in the databytes_all queryset has many attributes but one of them is publish_date.
I'd like to order the queryset by publish_date, however if publish_date is None, I'd like the item to be at the end of the queryset.
This is what I'm trying but it's not working:
databytes_all = DataByte.objects
Make a queryset: filter out all of the publish dates that are None
no_date = databytes_all.filter(publish_date=None)
Make anohther queryset: exclude all of the items where publish date is none, then order the remaining items by publish date
databytes_with_date = databytes_all.order_by('-publish_date').exclude(publish_date=None)
Now combine the two querysets (however this doesnt work- the items with no publish date are first in the list when I want them to be last)
databytes = databytes_with_date | no_date