1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[4.1.x] Fixed #34025 -- Fixed selecting ModelAdmin.autocomplete_fields after adding/changing related instances via popups.

Regression in c72f6f36c1.

Thanks Alexandre da Silva for the report.

Backport of 9976f3d4b8 from main
This commit is contained in:
David Sanders
2022-09-21 22:56:22 +10:00
committed by Mariusz Felisiak
parent 4f7fc378a1
commit 33d9247c8b
4 changed files with 56 additions and 24 deletions

View File

@@ -96,7 +96,8 @@
// Extract the model from the popup url '.../<model>/add/' or
// '.../<model>/<id>/change/' depending the action (add or change).
const modelName = path.split('/')[path.split('/').length - (objId ? 4 : 3)];
const selectsRelated = document.querySelectorAll(`[data-model-ref="${modelName}"] select`);
// Exclude autocomplete selects.
const selectsRelated = document.querySelectorAll(`[data-model-ref="${modelName}"] select:not(.admin-autocomplete)`);
selectsRelated.forEach(function(select) {
if (currentSelect === select) {