[Django] #33893: Admin add model page incorrectly redirects

8 views
Skip to first unread message

Django

unread,
Aug 4, 2022, 5:07:12 AM8/4/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
------------------------------------------+------------------------
Reporter: Fabian Jarrett | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 4.1
Severity: Normal | Keywords: admin
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
In the admin when clicking "add model +" I fill out the fields to create
my item then when I click "Save and add another" or "Save and continue
editing" it redirects back to the model list view even though the item was
added successfully. If I click back on to the item to edit it the buttons
work how they should.

Looks like "_addanother" isn't in the request.POST:
https://github.com/django/django/blob/main/django/contrib/admin/options.py#L1388

The name on the input isn't being passed with the form submit:
https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/submit_line.html#L6

If I comment out overriding the submit it works as expected:
https://github.com/django/django/blob/main/django/contrib/admin/static/admin/js/change_form.js#L11:L19

Also when editing an item that has already been created "modelName" is
undefined so the submit buttons don't get overridden:
https://github.com/django/django/blob/main/django/contrib/admin/static/admin/js/change_form.js#L8
So works when editing, but not when adding a new item.

I think this change is causing the issue?
https://github.com/django/django/commit/fe7dbef5867c577995f0fc849d8dfdb8f2e6bbfa

--
Ticket URL: <https://code.djangoproject.com/ticket/33893>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 4, 2022, 5:07:19 AM8/4/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
--------------------------------+------------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Normal | Resolution:

Keywords: admin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------
Changes (by Fabian Jarrett):

* owner: nobody => Fabian Jarrett
* status: new => assigned


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

Django

unread,
Aug 4, 2022, 5:53:06 AM8/4/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------

Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted

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

* cc: Carlton Gibson, Marcelo Galigniana (added)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

Thanks for the report! Regression in
fe7dbef5867c577995f0fc849d8dfdb8f2e6bbfa.

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

Django

unread,
Aug 4, 2022, 8:06:23 AM8/4/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

Maybe we should simply revert the regression commit, as it seems the
remedy is worse than the disease.

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

Django

unread,
Aug 4, 2022, 8:34:03 AM8/4/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

[https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit
HTMLFormElement.submit() (MDN)]:

{{{
<input> with attribute type="submit" will not be submitted with the form
when using HTMLFormElement.submit(), but it would be submitted when you do
it with original HTML form submit.
}}}

So I guess we'd need to add a hidden element for the button clicked...
gah... — leaning too overly complex (as per Claude's take.)

Marcelo do you have a thought here?

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:4>

Django

unread,
Aug 4, 2022, 9:05:15 AM8/4/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Marcelo Galigniana):

I can add the hidden input, but I'm agree with Claude: It would add
complexity+.

I am wondering if there is another strategy like we did in
https://github.com/django/django/pull/15229 (disable buttons, but it was
no good for accessibility).

Anyway, when I was working on this ticket, if I'm not wrong, after do a
double submission the user will see two notifications (toasts), right? So
it could manage the 'bug' deleting the second copy.

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:5>

Django

unread,
Aug 4, 2022, 2:22:55 PM8/4/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Agreed, let's revert it.

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:6>

Django

unread,
Aug 5, 2022, 2:33:29 AM8/5/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Fabian, Would you like to prepare a patch? You can use `git revert
fe7dbef5867c577995f0fc849d8dfdb8f2e6bbfa` and add release notes to the
`4.1.1.txt`.

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:7>

Django

unread,
Aug 5, 2022, 2:35:43 AM8/5/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Fabian Jarrett):

Replying to [comment:7 Mariusz Felisiak]:


> Fabian, Would you like to prepare a patch? You can use `git revert
fe7dbef5867c577995f0fc849d8dfdb8f2e6bbfa` and add release notes to the
`4.1.1.txt`.

Yea, I'll look into it.

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:8>

Django

unread,
Aug 5, 2022, 3:16:33 AM8/5/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Fabian Jarrett):

Fixed in this pull request: https://github.com/django/django/pull/15917

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:9>

Django

unread,
Aug 5, 2022, 3:36:19 AM8/5/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Fabian Jarrett):

I messed up a few PRs. Hopefully this one is all good!

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:10>

Django

unread,
Aug 5, 2022, 3:57:15 AM8/5/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:11>

Django

unread,
Aug 5, 2022, 10:39:58 AM8/5/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: admin | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:12>

Django

unread,
Aug 5, 2022, 11:21:49 AM8/5/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed

Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"0756c61f2ada56e4ae625589099c0141a77737eb" 0756c61f]:
{{{
#!CommitTicketReference repository=""
revision="0756c61f2ada56e4ae625589099c0141a77737eb"
Fixed #33893 -- Reverted "Fixed #28889 -- Prevented double submission of
admin forms."

Regression in fe7dbef5867c577995f0fc849d8dfdb8f2e6bbfa.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:13>

Django

unread,
Aug 5, 2022, 11:22:16 AM8/5/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"82e9e19ebe6bc920f1cfffc42d86648644fd4a78" 82e9e19]:
{{{
#!CommitTicketReference repository=""
revision="82e9e19ebe6bc920f1cfffc42d86648644fd4a78"
[4.1.x] Fixed #33893 -- Reverted "Fixed #28889 -- Prevented double
submission of admin forms."

Regression in fe7dbef5867c577995f0fc849d8dfdb8f2e6bbfa.

Backport of 0756c61f2ada56e4ae625589099c0141a77737eb from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:14>

Django

unread,
Aug 8, 2022, 1:10:06 AM8/8/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

#33904 was a related issue for many-to-many fields with filters.

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:15>

Django

unread,
Sep 4, 2022, 4:20:29 PM9/4/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by ADHD is DEV):

I don't get it, so was it "fixed" then or not? **I still have this
problem** and my ticket was closed bc it's a "duplicate" of this one.

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:16>

Django

unread,
Sep 4, 2022, 5:55:51 PM9/4/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

The fix will be released in Django 4.1.1.

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:17>

Django

unread,
Sep 23, 2022, 7:16:22 AM9/23/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Emanuel Angelo):

I've been testing version 4.1.1 and it still has the same problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:18>

Django

unread,
Sep 23, 2022, 8:06:54 AM9/23/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

Did you try after emptying the browser cache?

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:19>

Django

unread,
Sep 24, 2022, 12:37:34 PM9/24/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Emanuel Angelo):

Replying to [comment:19 Claude Paroz]:


> Did you try after emptying the browser cache?

I did not... and it worked flawlessly after I flushed it. I'm sorry for
writing the comment without first trying such a basic thing. What fooled
me was that I wasn't expecting content to be cached when running the
development server.

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:20>

Django

unread,
Sep 24, 2022, 1:22:41 PM9/24/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

If I thought about this, this means I was bitten by this, too (I reported
such a wrong issue not long ago!).

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:21>

Django

unread,
Sep 26, 2022, 2:43:21 PM9/26/22
to django-...@googlegroups.com
#33893: Admin add model page incorrectly redirects
-------------------------------------+-------------------------------------
Reporter: Fabian Jarrett | Owner: Fabian
| Jarrett
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: admin | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

> ...What fooled me was that I wasn't expecting content to be cached when
running the development server.

> If I thought about this, this means I was bitten by this, too (I


reported such a wrong issue not long ago!).

(Reading as those two clauses are directly related.)

Telling the browser **not** to cache in development (presumably by setting
an explicit max age of 0) was discussed in #32981 (see also #33148 and
#27572).
A trip via the DevelopersMailingList to discuss re-opening would be
available. (Generally I **want** the browser to cache even in development,
because otherwise it's hard to test the ''real behaviour'': developer
tools have commands to empty the cache, and toggles for disabling that
cache, with or without the web tools console open, so I'm not sure myself
there's a need to add it, but it may be worth a discussion.)

--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:22>

Reply all
Reply to author
Forward
0 new messages