#29700: Document ModelAdmin.autocomplete_view() and AutocompleteJsonView (as
customisation point).
--------------------------------------+------------------------------------
     Reporter:  David W. Lloyd        |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Documentation         |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

 * component:  contrib.admin => Documentation
 * version:  2.1 => master
 * type:  New feature => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 > ...you can make the same exact argument about the *existing* "ordering"
 field - why have it, when you can do the same thing by modifying the
 queryset?

 I think in the history of ModelAdmin itself, we've learnt that it's
 possible to have ''too much of a good thing'' when it comes to these
 declarative options.

 `ordering` has been there forever, and there's no realistic way we can
 take it out. **But** I don't think it's likely we'd add it again today.

 Instead I think we'd point to overriding `get_queryset()`, and just using
 a `orderBy`.

 {{{
 def get_queryset(self):
     return self.model.objects.orderBy('-name')
 }}}

 (... or such ...)

 That would do. It's roughly the same, or sometime less, code than
 specifying `ordering` & co.
 It's less magic. Less to remember. And less to have to go searching for
 when things behave unexpectedly.

 ''Mutatis mutandis'', I think in this case we should document
 `ModelAdmin.autocomplete_view()` and `AutocompleteJsonView` as the
 customisation point for the behaviour here.

 (If there are one or two key configuration options then **possibly**
 `AutocompleteJsonView` could take init kwargs to `as_view()` to avoid
 subclassing in every case, but any such addition would need assessing
 separately, and probably afterwards.)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29700#comment:4>
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.1fdbd8322f0b7dc78fb3cbc3c7ef3932%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to