1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Refs #10743 -- Enabled ordering for lookups in ModelAdmin.list_display.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Co-authored-by: Nina Menezes <https://github.com/nmenezes0>
This commit is contained in:
Tom Carrick
2023-11-16 09:11:27 +01:00
committed by Natalia
parent 4ade8386eb
commit 9cefdfc43f
3 changed files with 62 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ from django.contrib.admin.views.main import (
)
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.template import Library
from django.template.loader import get_template
from django.templatetags.static import static
@@ -112,7 +113,7 @@ def result_headers(cl):
# Set ordering for attr that is a property, if defined.
if isinstance(attr, property) and hasattr(attr, "fget"):
admin_order_field = getattr(attr.fget, "admin_order_field", None)
if not admin_order_field:
if not admin_order_field and LOOKUP_SEP not in field_name:
is_field_sortable = False
if not is_field_sortable: