The model has an IntegerField with null=True, blank=True, so it allows the field to have a value of None. When the column is sorted, the Nones are always treated as the lowest values. Is it possible to make Django treat them as the highest values? So when sorted in descending order, instead of:
100 43 7 None
It would go:
None 100 43 7
I realize I could assign an extremely high number instead of None, but for neatness’ sake, I was wondering if there were any other options.
Thanks!
Since I’m using Django 1.1 and couldn’t use
raw(), the simplest way turned out to be to create a “int_sort” field, and populate it with the value of theIntegerField, unless it encountered aNone, in which case it would take the value ofsys.maxint.Then, in
admin.py, I set theadmin_order_fieldto be the “int_sort” field.