#30981: Admin changelist crashes when using query expression in the ModelAdmin's
admin_order_field
-------------------------------+--------------------------------------
Reporter: Petr DlouhĂ˝ | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 2.2
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 Petr DlouhĂ˝):
Note: this is motivated by usage with `nulls_last` such as
`F('sum_amount').desc(nulls_last=True)`, which does throw a different
traceback:
{{{
Traceback (most recent call last):
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/core/handlers/exception.py",
line 34, in inner
response = get_response(request)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/core/handlers/base.py", line
115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/core/handlers/base.py", line
113, in _get_response
response = wrapped_callback(request, *callback_args,
**callback_kwargs)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/contrib/admin/options.py",
line 606, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/utils/decorators.py", line
142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/views/decorators/cache.py",
line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/contrib/admin/sites.py", line
223, in inner
return view(request, *args, **kwargs)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/utils/decorators.py", line 45,
in _wrapper
return bound_method(*args, **kwargs)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/utils/decorators.py", line
142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/contrib/admin/options.py",
line 1672, in changelist_view
cl = self.get_changelist_instance(request)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/contrib/admin/options.py",
line 744, in get_changelist_instance
sortable_by,
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/contrib/admin/views/main.py",
line 81, in __init__
self.queryset = self.get_queryset(request)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/contrib/admin/views/main.py",
line 436, in get_queryset
qs = qs.order_by(*ordering)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/db/models/query.py", line
1074, in order_by
obj.query.add_ordering(*field_names)
File "/home/petr/.local/share/virtualenvs/aklub_project-
HrPEZ5ak/lib/python3.6/site-packages/django/db/models/sql/query.py", line
1804, in add_ordering
if not hasattr(item, 'resolve_expression') and not
ORDER_PATTERN.match(item):
TypeError: expected string or bytes-like object
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30981#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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.41a8e91dd24c5f6cc09def4ba97699ac%40djangoproject.com.