#29700: Provide an "autocomplete_ordering" value in ModelAdmin, to decouple
autocomplete ordering from admin ordering
--------------------------------+--------------------------------------
Reporter: David W. Lloyd | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Carlton Gibson):
* cc: Johannes Hoppe (added)
Comment:
The use-case here seems reasonable enough, but I'm (initially) sceptical
about adding yet more API to ModelAdmin.
If that weren't an option, what would I do?
Well, I'd look to customise the autocomplete view:
{{{
def autocomplete_view(self, request):
return AutocompleteJsonView.as_view(model_admin=self)(request)
}}}
[https://github.com/django/django/blob/233c70f0479beb3bff9027e6cff680882978fd4d/django/contrib/admin/options.py#L1638-L1639
source]
Is there any reason I can't just override
[https://github.com/django/django/blob/233c70f0479beb3bff9027e6cff680882978fd4d/django/contrib/admin/views/autocomplete.py#L42-L48
`AutocompleteJsonView.get_queryset()`] to apply whatever ordering I need?
(It doesn't look like there is...)
`autocomplete_view()`/`AutocompleteJsonView`/&co are not documented, so
this ticket would amount to needing to add that (and maybe we make small
adjustments to the ModelAPI) but (for me, initially) this would help to
modularise the autocomplete options and be preferable to more top-level
ModelAdmin options.
Thoughts?
--
Ticket URL: <https://code.djangoproject.com/ticket/29700#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.6e87b30c47afac384a065cfe9b4c2c1c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.