#33394: inlines.js error in django.contrib.admin since Django 1.xx
-------------------------------------+-------------------------------------
Reporter: Maxim | Owner: nobody
Danilov |
Type: Bug | Status: new
Component: | Version: 4.0
contrib.admin | Keywords: admin, modeladmin,
Severity: Normal | inline, inline.js
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/33394>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.2605490b16338bc51599830b083ea47f%40djangoproject.com.