I got a model with a ForeignKey field, and I want the default listing of this model to be ordered by this field.
I get the correct `qs.query` SQL statement, but for some reason the admin listing is not following it. This is what I've done so far: class SomeAdminModel(admin.ModelAdmin): # ... fields def queryset(self, request): qs = super(SomeAdminModel, self).queryset(request) fk_list = [1,2,7,3,5,6,4] ordering = 'FIELD(`fk_field_id`, %s)' % ','.join(str(id) for id in fk_list) qs = qs.filter(fk_field__in = fk_list).extra( select = {'ordering': ordering}, order_by = ('ordering',) ) return qs What can be preventing this from behave as desired? Do I need to override anything else? Thanks in advance. -- Vinicius Massuchetto http://vinicius.soylocoporti.org.br -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.