Try the following:
Set the order in the Meta
model:
class Meta: ordering = ["some_field", "other_field"]
and add this class to admin.py
:
from django.contrib.admin.views.main import ChangeList class SpecialOrderingChangeList(ChangeList): """ Django 1.3 ordering problem workaround from 1.4 it enough to use `ordering` variable """ def get_query_set(self): queryset = super(SpecialOrderingChangeList, self).get_query_set() return queryset.order_by(*self.model._meta.ordering)
Add this method to admin.ModelAdmin
def get_changelist(self, request, **kwargs): return SpecialOrderingChangeList
source: https://groups.google.com/forum/?fromgroups#!topic/django-users/PvjClVVgD-s
user535010
source share