[Django] #36337: Broken autocomplete inside Inline after clicking "Add another ..."

8 views
Skip to first unread message

Django

unread,
Apr 19, 2025, 6:42:39 AM4/19/25
to django-...@googlegroups.com
#36337: Broken autocomplete inside Inline after clicking "Add another ..."
-------------------------------------+-------------------------------------
Reporter: Michał Pokusa | Type: Bug
Status: new | Component:
| contrib.admin
Version: 5.2 | Severity: Normal
Keywords: autocomplete inline | Triage Stage:
admin | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
This error occurs on versions from 3.2 (or even before, untested) up to
latest (5.2 at this time). It seems like it is only JS/CSS related.
Happens with both `TabularInline` and `StackedInline`.

Possibly related to #36336.

Tested on Google Chrome, Firefox, Edge and on mobile device.

Steps to reproduce (code below):
1. Go to change form view (editing existing object, adding new one,
doesn't matter)
2. Click "X" on any inline except last one
3. Click "Add another ..." once again


[[Image(https://raw.githubusercontent.com/michalpokusa/static-django-
tickets/refs/heads/main/36337/2025-04-19%2012%2016%2000.png)]]


Code:
== models.py
{{{#!python
from django.db import models


class Restaurant(models.Model):
name = models.CharField(max_length=100)
address = models.CharField(max_length=255)

def __str__(self):
return self.name


class Order(models.Model):
restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE)
order_number = models.CharField(max_length=20)
products = models.ManyToManyField("Product", related_name="orders")

def __str__(self):
return f"Order {self.pk} from {self.restaurant.name}"


class Product(models.Model):
name = models.CharField(max_length=100)
price = models.DecimalField(max_digits=10, decimal_places=2)

def __str__(self):
return f"{self.name} - ${self.price}"
}}}

== admin.py
{{{#!python
from django.contrib import admin

from .models import Restaurant, Order, Product


class OrderInline(admin.StackedInline):
model = Order
extra = 3

fields = ["order_number", "products"]
autocomplete_fields = ["products"]


@admin.register(Restaurant)
class RestaurantAdmin(admin.ModelAdmin):
list_display = ("name", "address")
search_fields = ("name", "address")

inlines = [OrderInline]


@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
list_display = ("restaurant", "order_number")


@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
list_display = ("name", "price")

search_fields = ("name",)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36337>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 21, 2025, 10:49:36 AM4/21/25
to django-...@googlegroups.com
#36337: Broken autocomplete inside Inline after clicking "Add another ..."
-------------------------------------+-------------------------------------
Reporter: Michał Pokusa | Owner: (none)
Type: Bug | Status: new
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: autocomplete inline | Triage Stage: Accepted
admin |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* stage: Unreviewed => Accepted
* version: 5.2 => dev

Comment:

Thank you Michał Pokusa, I was able to reproduce this issue with the
provided steps.
--
Ticket URL: <https://code.djangoproject.com/ticket/36337#comment:1>

Django

unread,
Apr 21, 2025, 11:09:48 AM4/21/25
to django-...@googlegroups.com
#36337: Broken autocomplete inside Inline after clicking "Add another ..."
-------------------------------------+-------------------------------------
Reporter: Michał Pokusa | Owner: Ahmed
| Nassar
Type: Bug | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: autocomplete inline | Triage Stage: Accepted
admin |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Ahmed Nassar):

* owner: (none) => Ahmed Nassar
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36337#comment:2>
Reply all
Reply to author
Forward
0 new messages