summaryrefslogtreecommitdiff
path: root/django/contrib/admin/utils.py
AgeCommit message (Collapse)Author
2026-04-22Fixed #10919 -- Added delete_confirmation_max_display to ModelAdmin.Rodrigo Vieira
The new ModelAdmin.delete_confirmation_max_display attribute allows limiting the number of related objects shown on the delete confirmation page. When the limit is reached, a "…and N more objects." message is shown. The feature relies on a new truncated_unordered_list template filter added to django.contrib.admin.templatetags.admin_filters. Thanks Jacob Tyler Walls for the review and guidance, Tobias McNulty for the report, and terminator14 for the solution suggested.
2026-03-18Fixed #36926 -- Made admin use boolean icons for related BooleanFields in ↵huwaiza tahir
list_display. When using related field lookups like 'parent__is_active' in list_display, the admin now correctly detects if the final field is a BooleanField and displays boolean icons instead of 'True'/'False' text. Modified lookup_field() in django/contrib/admin/utils.py to retrieve the final field from the path when traversing relations using LOOKUP_SEP (__), allowing display_for_field() to properly handle BooleanFields.
2026-02-20Fixed #36127 -- Applied default empty display value to links otherwise ↵SiHyunLee
containing only whitespace in admin.
2026-01-16Fixed #36801 -- Avoided unnecessary calculation in construct_change_message().Adam Johnson
`changed_field_labels` is only needed if there are changes to log, so move its calculation, including the somewhat costly `translation_override()`, inside the conditional that checks for changes. Also avoid reading `form.changed_data` when it’s already bound to `changed_data`. co-authored-by: Rodolfo Becerra <44782644+rodolvbg@users.noreply.github.com>
2025-10-18Fixed #21961 -- Added support for database-level delete options for ForeignKey.Mariusz Felisiak
Thanks Simon Charette for pair programming. Co-authored-by: Nick Stefan <NickStefan12@gmail.com> Co-authored-by: Akash Kumar Sen <71623442+Akash-Kumar-Sen@users.noreply.github.com> Co-authored-by: Simon Charette <charette.s@gmail.com>
2025-07-23Refs #36500 -- Rewrapped long docstrings and block comments via a script.django-bot
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
2025-04-17Fixed #35959 -- Displayed password reset button in admin only when user has ↵Sarah Boyce
sufficient permissions. This change ensures that the "Reset password" button in the admin is shown only when the user has the necessary permission to perform a password change operation. It reuses the password hashing rendering logic in `display_for_field` to show the appropriate read-only widget for users with view-only access.
2025-01-10Fixed #36032 -- Rendered URLField values as links in the admin.antoliny0919
2025-01-08Fixed #36063 -- Made a FileField navigate to the object admin change page ↵antoliny0919
when in list_display_links.
2024-02-05Fixed #10743 -- Allowed lookups for related fields in ModelAdmin.list_display.Tom Carrick
Co-authored-by: Alex Garcia <me@alexoteiza.com> Co-authored-by: Natalia <124304+nessita@users.noreply.github.com> Co-authored-by: Nina Menezes <https://github.com/nmenezes0>
2024-01-11Refs #28404 -- Made displaying property values in admin respect non-None ↵Alexander Lazarević
empty values.
2024-01-10Fixed #28404 -- Made displaying values in admin respect Field's empty_values.Alexander Lazarević
2023-09-16Fixed #31558 -- Added support for boolean attribute on properties in ↵Ryanwalker277
ModelAdmin.list_display.
2023-07-07Fixed #9602 -- Added AdminSite.get_model_admin().Mariusz Felisiak
This allows retrieving an admin class for the given model class without using internal attributes.
2023-07-06Used AdminSite.is_registered() where appropriate.Mariusz Felisiak
2023-03-16Fixed #1873 -- Handled multi-valued query parameters in admin changelist ↵sarahboyce
filters.
2023-03-16Refs #1873 -- Used GET.lists() in admin filters.sarahboyce
2022-08-23Fixed #33927 -- Fixed crash when displaying ArrayField with choices in admin.David Wobrock
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2022-01-11Fixed #13251 -- Made pre/post_delete signals dispatch the origin.mgaligniana
2021-12-08Fixed #19721 -- Allowed admin filters to customize the list separator.Shreya Bamne
2021-11-03Fixed #32996 -- Cached PathInfos on relations.Keryn Knight
PathInfo values are ostensibly static over the lifetime of the object for which they're requested, so the data can be memoized, quickly amortising the cost over the process' duration.
2021-07-29Fixed 32956 -- Lowercased spelling of "web" and "web framework" where ↵David Smith
appropriate.
2021-04-29Refs #32682 -- Renamed lookup_needs_distinct() to lookup_spawns_duplicates().Mariusz Felisiak
Follow up to 187118203197801c6cb72dc8b06b714b23b6dd3d.
2020-10-09Fixed #32080 -- Fixed displaying Unicode chars in forms.JSONField and ↵Qi Zhao
read-only JSONField values in admin.
2020-05-11Refs #30116 -- Simplified regex match group access with Match.__getitem__().Jon Dufresne
The method has been available since Python 3.6. The shorter syntax is also marginally faster.
2020-05-08Fixed #31157 -- Fixed displaying read-only JSONField values in admin.dbxnr
2020-04-27Removed unnecessary tuple wrapping of single format string argument.François Freitag
2019-11-19Fixed #27272 -- Added an on_delete RESTRICT handler to allow cascading ↵Daniel Izquierdo
deletions while protecting direct ones.
2019-10-29Fixed #30899 -- Lazily compiled import time regular expressions.Hasan Ramezani
2019-10-09Fixed #30856 -- Combined fast-delete queries by model during cascade deletion.Simon Charette
Reduced the number of queries required when performing cascade deletion for a model referenced multiple time by another one by performing an union of reference lookups.
2019-06-14Fixed #12952 -- Adjusted admin log change messages to use form labels ↵Sanyam Khurana
instead of field names.
2018-10-02Simplified contrib.admin.utils.unquote().Sergey Fedoseev
2018-10-01Simplified contrib.admin.utils.quote().Sergey Fedoseev
2018-08-20Fixed #29682 -- Fixed admin change form crash if a view-only model's form ↵Tim Graham
has an extra field.
2018-06-15Fixed #23869 -- Made ModelAdmin.get_deleted_objects() use ↵Henk Kahlfuß
has_delete_permission() for permissions checking.
2018-03-20Refs #29227 -- Simplified NullBooleanField by making it subclass BooleanField.Nick Pope
2018-03-20Fixed #29227 -- Allowed BooleanField to be null=True.Tim Graham
Thanks Lynn Cyrin for contributing to the patch, and Nick Pope for review.
2018-02-24Removed using argument from admin's get_deleted_objects().Tim Graham
2018-02-21Removed unused opts argument from admin's get_deleted_objects().Tim Graham
Unused since e12b3199d0c01694ca6b09add5e0f27cadffc8ad.
2018-01-12Fixed #28996 -- Simplified some boolean constructs and removed trivial ↵Дилян Палаузов
continue statements.
2018-01-04Fixed #28517 -- Fixed admin delete confirmation view crash when related ↵Paulo
models don't have a delete permission.
2018-01-03Fixed #28986 -- Prevented boolean values in admin list display from being ↵Jonas Haag
formatted with thousand separators.
2018-01-03Fixed #28985 -- Removed unneeded None checks before hasattr().Дилян Палаузов
2017-11-18Fixed #26184 -- Allowed using any lookups in ModelAdmin.search_fields.Krzysztof Nazarewski
Thanks Krzysztof Nazarewski for the initial patch.
2017-10-31Refs #23919 -- Updated references to urllib.quote() to Python 3 location.Ville Skyttä
2017-09-13Merged isinstance() calls.Mariusz Felisiak
2017-06-05Replaced Model._get_pk_val() with pk property.Tim Graham
Model.pk was added after _get_pk_val() and many places weren't simplified.
2017-04-27Refs #27795 -- Replaced many force_text() with str()Claude Paroz
Thanks Tim Graham for the review.
2017-03-15Fixed #27897 -- Fixed crash with 'pk' in ModelAdmin.search_filters.Josh Schneier