[Django] #34960: Document how to set nulls_last=True for admin_order_field/ordering

14 views
Skip to first unread message

Django

unread,
Nov 9, 2023, 4:48:35 AM11/9/23
to django-...@googlegroups.com
#34960: Document how to set nulls_last=True for admin_order_field/ordering
-----------------------------------------+------------------------
Reporter: Petr Dlouhý | Owner: nobody
Type: New feature | Status: new
Component: Documentation | Version: 4.2
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 |
-----------------------------------------+------------------------
Django in https://code.djangoproject.com/ticket/30981 added possibility to
set `nulls_last=True` for field ordering in `ModelAdmin` as:

{{{
my_model_admin.admin_order_field = F('field').desc(nulls_last=True)
}}}

or

{{{
@admin.display(ordering=F('field').desc(nulls_last=True))
}}}

but I can't any mention of it at
https://docs.djangoproject.com/en/4.2/ref/contrib/admin/.
In fact I had to find the original issue I report it to set this up
correctly.

Would it be possible to mention all possible values of
admin_order_field/ordering in the documentation?

--
Ticket URL: <https://code.djangoproject.com/ticket/34960>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 9, 2023, 5:11:32 AM11/9/23
to django-...@googlegroups.com
#34960: Document how to set nulls_last=True for admin_order_field/ordering
-------------------------------------+-------------------------------------

Reporter: Petr Dlouhý | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 4.2
Severity: Normal | Resolution: wontfix

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 Mariusz Felisiak):

* status: new => closed
* type: New feature => Cleanup/optimization
* resolution: => wontfix


Comment:

Thanks for the ticket. #30981 fixed a bug, not added a new feature. All
database expressions can be used in `ordering` and it's not an admin-
specific feature. Moreover, docs already explain how to sort `NULL`s in a
few places:
- https://docs.djangoproject.com/en/stable/ref/models/expressions/#using-f
-to-sort-null-values
-
https://docs.djangoproject.com/en/stable/ref/models/options/#django.db.models.Options.ordering
- https://docs.djangoproject.com/en/stable/ref/models/querysets/#order-by
some of them are reference in the Admin docs. I don't think it's worth
mentioning in the next place.

--
Ticket URL: <https://code.djangoproject.com/ticket/34960#comment:1>

Reply all
Reply to author
Forward
0 new messages