Re: [Django] #29700: Provide an "autocomplete_ordering" value in ModelAdmin, to decouple autocomplete ordering from admin ordering

2018-08-22 Thread Django
#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 David W. Lloyd):

 Replying to [comment:2 Johannes Hoppe]:
 > Replying to [comment:1 Carlton Gibson]:
 > >
 > > 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.

 I agree, that's a fine way to achieve the functionality, and if
 AutocompleteJsonView gets a bit more documentation, I guess that would be
 the default approach?

 But my thinking is as follows: 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 personally believe the answer is: "Because it's a common enough use case
 that having a dedicated field makes it easier, more intuitive, and more
 explicit" - all of which are good things, and I think they apply to the
 autocomplete sorting the same as they do the ModelAdmin sorting.

 Yes, that comes at the cost of adding another field to the API, but that's
 going to be the case with anything you want to make more
 explicit/intuitive. If there was an interest in conserving fields, it
 could be a dict? like:

 {{{
 autocomplete_view_options = {'ordering': 'name,
 'other_useful_parameter_to_be_added_in_future': 'maybe?'}
 }}}

 ...either way, while I see how to achieve the functionality in question
 myself and will have no problem whatsoever doing so, I still believe that
 the explicit decoupling would make sense, either via a single
 "autocomplete_ordering" field or a dict of extensible options including,
 initially, ordering.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.3e834aa2f84cb6681abb6d7064f89eb0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29700: Provide an "autocomplete_ordering" value in ModelAdmin, to decouple autocomplete ordering from admin ordering

2018-08-22 Thread Django
#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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
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.


Re: [Django] #29700: Provide an "autocomplete_ordering" value in ModelAdmin, to decouple autocomplete ordering from admin ordering

2018-08-22 Thread Django
#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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
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.


[Django] #29700: Provide an "autocomplete_ordering" value in ModelAdmin, to decouple autocomplete ordering from admin ordering

2018-08-21 Thread Django
#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  |   Keywords:
   Triage Stage:  Unreviewed  |  Has patch:  0
Needs documentation:  0   |Needs tests:  0
Patch needs improvement:  0   |  Easy pickings:  0
  UI/UX:  0   |
--+
 Reference: https://code.djangoproject.com/ticket/29010#comment:7

 The new autocomplete view uses whatever ordering the ModelAdmin specifies,
 but most of the time you'd want autocomplete to be alphabetized so that
 typeahead suggestions make more sense and can be scanned visually. My
 particular use case is that I want certain admins to default to showing
 the most recently edited objects, but this sort order makes no sense for
 autocomplete views in lookups from related object change forms.

 This seems like a common enough use case to warrant built-in decoupling of
 sort order for autocomplete view from ModelAdmin's standard "ordering"
 field.

 Proposed improvement/feature would be an "autocomplete_ordering" field and
 corresponding "get_autocomplete_ordering" method which default to using
 the "ordering" but can be easily overridden, readily providing decoupling
 when needed.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.cf738be453960e6c87eeb93116f60d0e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.