[Django] #33394: inlines.js error in django.contrib.admin since Django 1.xx

12 views
Skip to first unread message

Django

unread,
Dec 29, 2021, 4:17:59 AM12/29/21
to django-...@googlegroups.com
#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.

Django

unread,
Dec 29, 2021, 4:56:37 AM12/29/21
to django-...@googlegroups.com
#33394: Adding inlines doesn't work with a manually crafted HTML.
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: invalid
Keywords: admin, modeladmin, | Triage Stage:
inline, inline.js | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* type: Bug => Cleanup/optimization
* has_patch: 1 => 0
* resolution: => invalid


Comment:

> This is not impossible situation, i include additional inline for my
needs directly in html, and founded this bug.

Thanks for the report, however I don't think it's something that we would
like (or need) to support.

--
Ticket URL: <https://code.djangoproject.com/ticket/33394#comment:1>

Django

unread,
Dec 29, 2021, 5:10:53 AM12/29/21
to django-...@googlegroups.com
#33394: Adding inlines doesn't work with a manually crafted HTML.
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: nobody
Type: | Status: new

Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin, modeladmin, | Triage Stage:
inline, inline.js | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Maxim Danilov):

* status: closed => new
* resolution: invalid =>


Comment:

inline.js has a bug: document.onready add link to wrong html tag.
It can be reproduced, and it has patch.

Why it should be not changed?

--
Ticket URL: <https://code.djangoproject.com/ticket/33394#comment:2>

Django

unread,
Dec 29, 2021, 5:17:39 AM12/29/21
to django-...@googlegroups.com
#33394: Adding inlines doesn't work with a manually crafted HTML.
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: invalid

Keywords: admin, modeladmin, | Triage Stage:
inline, inline.js | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed

* resolution: => invalid


Comment:

Because, as far as I'm aware it's not a supported scenario. If you can
provide a sample project that reproduces this issue without steps based on
manual modification of the generated HTML, then we can reconsider this
decision.

--
Ticket URL: <https://code.djangoproject.com/ticket/33394#comment:3>

Reply all
Reply to author
Forward
0 new messages