Opened 4 years ago

Closed 4 years ago

#32615 closed Cleanup/optimization (duplicate)

Autocomplete does not honor model ordering

Reported by: Matija Kolarić Owned by: nobody
Component: contrib.admin Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,
thanks for all the great work with Django, and especially Admin.

As said, autocomplete does not honor model ordering if admin ordering is not specified.

I would suggest something along these lines in BaseModelAdmin:

    def get_ordering(self, request):
        """
        Hook for specifying field ordering.
        """
        return self.ordering or self.model._meta.ordering

Of course, this suggestion does not cover probable edge cases (no model, no ordering, etc). But, at this point, I guess, the question is whether this would be better, as there might be some background reason not to do it this way.

Change History (1)

comment:1 by Mariusz Felisiak, 4 years ago

Resolution: duplicate
Status: newclosed
Type: UncategorizedCleanup/optimization

It's duplicate of #29700, you can override ​AutocompleteJsonView.get_queryset() to apply whatever ordering you need.

Note: See TracTickets for help on using tickets.
Back to Top