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.
* owner: nobody => Fabian Jarrett
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:1>
* 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>
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>
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>
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>
Comment (by Mariusz Felisiak):
Agreed, let's revert it.
--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:6>
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>
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>
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>
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>
* has_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:11>
* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:12>
* 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>
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>
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>
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>
Comment (by Tim Graham):
The fix will be released in Django 4.1.1.
--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:17>
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>
Comment (by Claude Paroz):
Did you try after emptying the browser cache?
--
Ticket URL: <https://code.djangoproject.com/ticket/33893#comment:19>
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>
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>
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>