#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
--------------------------------+--------------------------------------
Comment (by Johannes Hoppe):
Replying to [comment:1 Carlton Gibson]:
> The use case here seems reasonable enough, but I'm (initially) skeptical
about adding yet more API to ModelAdmin.
That is a reasonable concern. The `ModelAdmin` is practically exploding.
However that should not keep us from making changes, but only from blindly
adding features.
Maybe there is a better way though as you suggest later.
> 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?
That is not a bad way, this is how I would go about it myself too.
Actually this way you can add all sorts of extra functionality.
--
Ticket URL: <https://code.djangoproject.com/ticket/29700#comment:2>
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.67f264fd6bb3d128586369f4b6ed7c20%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.