﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33394	Adding inlines doesn't work with a manually crafted HTML.	Maxim Danilov	nobody	"We have a very old bug in inlines.js from django\contrib\admin\static\admin\js.

error in  inlines.js from row 327, method document.onready

How to reproduce:
1. Create admin form with any inline.
2. Open change form in browser, сopy whole html tag with class="".js-inline-admin-formset"" and with childs.
3. Override admin/change_form.html and add copy html part from 2. before admin form. Of cause all ""id"" in tags should be unique.

Now every time if change_form is opened,  inlines.js made wrong add_new_inline_object link.

Why:
in inlines.js any methods stackedFormset or tabularFormset don't check ""id"" from formset and add link to any formset with childs with class ""...-group"" and  "".inline-related"". 

Has Patch: yes.

{{{
//  django\contrib\admin\static\admin\js\inlines.js
// row 335:
$(selector).stackedFormset(selector, inlineOptions.options);
// change to 
$(this).find(""[id^="" + inlineOptions.name.substring(1) + ""-]"").stackedFormset(selector, inlineOptions.options);

// rows 338-339:
selector = inlineOptions.name + ""-group .tabular.inline-related tbody:first > tr.form-row"";
$(selector).tabularFormset(selector, inlineOptions.options);
// change to 
selector = inlineOptions.name + ""-group .tabular.inline-related tbody:first > tr[id^="" + inlineOptions.name.substring(1) + ""-].form-row "";
$(this).children().tabularFormset(selector, inlineOptions.options);
}}}

I only add ""id"" from every inline in jquery selector.

This is not impossible situation, i include additional inline for my needs directly in html, and founded this bug."	Cleanup/optimization	closed	contrib.admin	4.0	Normal	invalid	admin, modeladmin, inline, inline.js		Unreviewed	0	0	0	0	1	0
