summaryrefslogtreecommitdiff
path: root/django/contrib/admin/options.py
AgeCommit message (Collapse)Author
3 daysRefs #15759 -- Fixed ModelAdmin.list_editable form submission for ↵Artyom Kotovskiy
non-editable instances. Added formset that excludes objects for which user has no permission for POST formset as well. Fixed regression test: the test was not simulating real behaviour properly. By providing full form data for the post request we skipped the part where the user was actually limited in permissions and only modified some of the rows. Improved tests by getting rid of obj.id % 2 approach for granting permissions per object for users, since it is not the safest. Instead granting permissions simply by 'alive' parameter, which is simpler and more stable. Bug in 84db026228413dda4cd195464554d51c0b208e32.
9 daysFixed #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.
9 daysFixed #35870 -- Made blank choice label in forms more accessible.Annabelle Wiegart
Added new constant django.db.models.fields.BLANK_CHOICE_LABEL for an accessible and translatable blank choice label in forms. Deprecated django.db.models.fields.BLANK_CHOICE_DASH constant. Added the immediately deprecated transitional setting USE_BLANK_CHOICE_DASH. Co-Authored-By: Marijke Luttekes <mail@marijkeluttekes.dev>
9 daysFixed #15759 -- Excluded fields by per-object permissions for ↵Artyom Kotovskiy
ModelAdmin.list_editable. Instead of going over all objects in a queryset and filtering by user permissions, added skipping while saving the formset so there is no need to refetch objects again.
9 daysRefs #15759 -- Factored out _save_formset() in ModelAdmin.Artyom Kotovskiy
2026-04-07Fixed CVE-2026-4292 -- Disallowed instance creation via ↵Jacob Walls
ModelAdmin.list_editable. Thanks Natalia Bidart, Jake Howard, and Markus Holtermann for reviews.
2026-02-20Fixed #36127 -- Applied default empty display value to links otherwise ↵SiHyunLee
containing only whitespace in admin.
2026-02-11Fixed #36921 -- Fixed KeyError in inline form for model not registered with ↵Sean Helvey
admin. Regression in b1ffa9a9d78b0c2c5ad6ed5a1d84e380d5cfd010.
2026-01-30Fixed #36865 -- Removed casting from exact lookups in admin searches.mlissner
Instead of casting non-text fields to CharField (which prevents index usage), skip exact lookups when the search term fails formfield.to_python(). This preserves index usage for valid searches while gracefully handling invalid search terms by simply not including them in the query for that field. For multi-term searches like 'foo 123' on search_fields=['name', 'age__exact']: - 'foo': invalid for age, so only name lookup is used - '123': valid for both, so both lookups are used This entails a slight increase in permissiveness for search terms that can be normalized by formfield.to_python().
2026-01-22Fixed #13883 -- Rendered named choice groups with <optgroup> in ↵seanhelvey
FilteredSelectMultiple. This patch adds support for <optgroup>s in FilteredSelectMultiple widgets. When a popup returns a new object, if the source field contains optgroup choices, the optgroup is now also included in the response data. Additionally, this adds error handling for invalid source_model parameters to prevent crashes and display user-friendly error messages instead. Co-authored-by: Michael McLarnon <mmclar@gmail.com>
2026-01-12Fixed #36708 -- Initialized formset to None in ChangeList.__init__().Rudraksha Dwivedi
Thanks Antoliny for the review.
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-07-23Refs #36500 -- Shortened some long docstrings and comments.Mike Edmunds
Manually reformatted some long docstrings and comments that would be damaged by the to-be-applied autofixer script, in cases where editorial judgment seemed necessary for style or wording changes.
2025-07-23Removed double spaces after periods and within phrases.Sarah Boyce
2025-03-31Refs #28909 -- Simplified code using unpacking generalizations.Aarni Koskela
2025-03-12Fixed #36234 -- Restored single_object argument to ↵Adam Johnson
LogEntry.objects.log_actions(). Thank you Adam Johnson for the report and fix. Thank you Sarah Boyce for your spot on analysis. Regression in c09bceef68e5abb79accedd12dade16aa6577a09, which is partially reverted in this branch. Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2025-03-04Fixed #36217 -- Restored pre_save/post_save signal emission via ↵antoliny0919
LogEntry.save() for single-object deletion in the admin. Regression in 40b3975e7d3e1464a733c69171ad7d38f8814280. Thanks smiling-watermelon for the report. Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2025-01-15Refs #34462 -- Removed ModelAdmin.log_deletion() and ↵Sarah Boyce
LogEntryManager.log_action() per deprecation timeline.
2025-01-15Refs #22569 -- Made request required in ModelAdmin.lookup_allowed() per ↵Sarah Boyce
deprecation timeline.
2024-11-05Refs #26001 -- Handled relationship exact lookups in ModelAdmin.search_fields.Sarah Boyce
2024-11-04Fixed #26001 -- Fixed non-string field exact lookups in ↵0saurabh0
ModelAdmin.search_fields.
2024-08-07Fixed #35639 -- Improved admin's delete confirmation page title.Matthias Kestenholz
2024-07-18Fixed #35606, Refs #34045 -- Fixed rendering of ModelAdmin.action_checkbox ↵Hisham Mahmood
for models with a __html__ method. Thank you Claude Paroz for the report. Regression in 85366fbca723c9b37d0ac9db1d44e3f1cb188db2.
2024-07-04Fixed #35520 -- Avoided opening transaction for read-only ModelAdmin requests.Jake Howard
2024-05-29Fixed 35467 -- Replaced urlparse with urlsplit where appropriate.Jake Howard
This work should not generate any change of functionality, and `urlsplit` is approximately 6x faster. Most use cases of `urlparse` didn't touch the path, so they can be converted to `urlsplit` without any issue. Most of those which do use `.path`, simply parse the URL, mutate the querystring, then put them back together, which is also fine (so long as urlunsplit is used).
2024-05-22Fixed #35189 -- Improved admin collapsible fieldsets by using <details> ↵Marijke Luttekes
elements. This work improves the accessibility of the add and change pages in the admin site by adding <details> and <summary> elements to the collapsible fieldsets. This has the nice side effect of no longer requiring custom JavaScript helpers to implement the fieldsets' show/hide capabilities. Thanks to James Scholes for the accessibility advice, and to Sarah Boyce and Tom Carrick for reviews. Co-authored-by: Natalia <124304+nessita@users.noreply.github.com> Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-02-21Fixed #35237 -- Merged system checks for admin actions.Adam Johnson
2024-02-14Fixed #35173 -- Fixed ModelAdmin.lookup_allowed() for lookups on foreign ↵Hisham Mahmood
keys when not included in ModelAdmin.list_filter. Regression in f80669d2f5a5f1db9e9b73ca893fefba34f955e7. Thanks Sarah Boyce for the review.
2024-01-26Applied Black's 2024 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/24.1.0
2024-01-08Fixed #35087 -- Reallowed filtering against foreign keys not listed in ↵Sarah Boyce
ModelAdmin.list_filters. Regression in f80669d2f5a5f1db9e9b73ca893fefba34f955e7.
2023-12-07Fixed #35020 -- Fixed ModelAdmin.lookup_allowed() for non-autofield primary ↵Sarah Boyce
keys. Thanks Joshua Goodwin for the report. Regression in 45ecd9acca9b36093e274f47b6877a5f79108d9e.
2023-10-31Fixed #34462 -- Made admin log actions in bulk.Akash Kumar Sen
This also deprecates ModelAdmin.log_deletion() and LogEntryManager.log_action().
2023-10-17Removed unreachable code from ModelAdmin.response_change().Mariana
ModelAdmin.response_add() is always used when _saveasnew is set.
2023-10-11Fixed #12241 -- Preserved query strings when using "Save and continue/add ↵Mariana
another" in admin. Co-authored-by: Grady Yu <gradyy@users.noreply.github.com> Co-authored-by: David Sanders <shang.xiao.sanders@gmail.com> Co-authored-by: Matthew Newton <matthewn@berkeley.edu>
2023-07-07Refs #9602 -- Moved AlreadyRegistered/NotRegistered exceptions to ↵Mariusz Felisiak
django.contrib.admin.exceptions.
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-04-17Fixed #22569 -- Made ModelAdmin.lookup_allowed() respect get_list_filter().sarahboyce
Thank you Simon Meers for the initial patch.
2023-03-28Fixed #28384 -- Fixed ModelAdmin.lookup_allowed() for OneToOneField primary ↵sarahboyce
keys and nested relations.
2023-03-03Fixed #32539 -- Added toggleable facet filters to ModelAdmin.sarahboyce
Thanks Carlton Gibson, Simon Willison, David Smith, and Mariusz Felisiak for reviews.
2023-02-16Fixed #34045 -- Improved accessibility of selecting items in admin changelist.Durval Carvalho
This adds "aria-label".
2023-02-01Refs #33476 -- Applied Black's 2023 stable style.David Smith
Black 23.1.0 is released which, as the first release of the year, introduces the 2023 stable style. This incorporates most of last year's preview style. https://github.com/psf/black/releases/tag/23.1.0
2023-01-18Refs #34233 -- Used str.removeprefix()/removesuffix().Mariusz Felisiak
2022-11-08Fixed typo in BaseModelAdmin.has_delete_permission()'s docstring.Marco Marra
2022-10-31Used more augmented assignment statements.Nick Pope
Identified using the following command: $ git grep -I '\(\<[_a-zA-Z0-9]\+\>\) *= *\1 *[-+/*^%&|<>@]'
2022-10-06Fixed #32603 -- Made ModelAdmin.list_editable use transactions.Shubh1815
2022-09-24Fixed #34023 -- Added inline argument to user_deleted_form().Michał Pasternak
This binds the loop variable.
2022-09-15Changed camel case variable to snake case in contrib.admin/auth.Youngkwang Yang
2022-07-27Refs #32948, Refs #32946 -- Used Q.create() internally for dynamic Q() objects.Nick Pope
Node.create() which has a compatible signature with Node.__init__() takes in a single `children` argument rather than relying in unpacking *args in Q.__init__() which calls Node.__init__(). In addition, we were often needing to unpack iterables into *args and can instead pass a list direct to Node.create().
2022-07-25Fixed typo in django/contrib/admin/options.py comment.Ikko Ashimine
2022-06-28Fixed #33805 -- Made admin's many-to-many widgets do not display help text ↵Ankur
for selecting values when allow_multiple_selected is False.