Ordering display items by string id in Django-Admin
I have a static data table loaded via initial_data.json. The admin interface appears to display data in descending order by pk; that is, the records with the highest pk are at the top of the list. I would like to reverse this, ideally using the pk value. Since this is static data, I could add another column for the sort order, but this essentially duplicates the pk values, or I could use "pk = len (data) -i" instead of "pk = i" when creating my fixture file which I am currently using. But actually I would like to just say something like this:
class DataAdmin(admin.ModelAdmin):
ordering = ('row_id',)
I've tried using 'row_id', 'id' and 'pk', with no success. Does anyone have any ideas? Am I going to a diving source? Thank!
+3
source to share