mirror of
https://github.com/django/django.git
synced 2026-02-09 02:49:25 +08:00
Fixed #36468 -- Fixed failure to close popup when adding a related object in the admin.
The issue manifested when there were multiple relations and only some
of them participated in a filter_horizontal.
Regression in cd0479ff76.
This commit is contained in:
committed by
Jacob Walls
parent
4cecf30395
commit
08a0b92329
@@ -111,7 +111,12 @@
|
||||
option = new Option(newRepr, newId);
|
||||
select.options.add(option);
|
||||
// Update SelectBox cache for related fields.
|
||||
if (window.SelectBox !== undefined && !SelectBox.cache[currentSelect.id]) {
|
||||
if (
|
||||
window.SelectBox !== undefined
|
||||
&& !SelectBox.cache[currentSelect.id]
|
||||
// Only if SelectBox is managing that field.
|
||||
&& SelectBox.cache[select.id]
|
||||
) {
|
||||
SelectBox.add_to_cache(select.id, option);
|
||||
// Sort if there are any groups present
|
||||
if (SelectBox.cache[select.id].some(item => item.group)) {
|
||||
|
||||
@@ -1196,3 +1196,7 @@ class CamelCaseModel(models.Model):
|
||||
class CamelCaseRelatedModel(models.Model):
|
||||
m2m = models.ManyToManyField(CamelCaseModel, related_name="m2m")
|
||||
fk = models.ForeignKey(CamelCaseModel, on_delete=models.CASCADE, related_name="fk")
|
||||
# Add another relation that will not participate in filter_horizontal.
|
||||
fk2 = models.ForeignKey(
|
||||
CamelCaseModel, on_delete=models.CASCADE, related_name="fk2"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user