Fix the defaults around the Save buttons in Settings/Model Change forms.
Review Request #11344 — Created Dec. 23, 2020 and submitted
The new template for the change forms tried to use defaults if variables
for controlling the presence of the Save buttons weren't provided.
However, it did this using
|default:True, which meant that a value of
Falsewould be turned into
True. Not what we wanted.
That, however, was put in place (in change 663f50d) in order to fix a
prior (incorrect) attempt that used
|default_if_none. That could have
worked if that filter considered a missing variable to be equivalent to
None, but it didn't.
Even with these attempts, we had two code paths for generating that
template: Ours, and Django's, depending on whether a change form was
This change implements a more future-proof, reliable attempt at
generating these buttons. We now have a dedicated template tag that
covers the logic in Django's own
submit_rowtemplate tag and our own
logic, and expands upon that to allow greater customization by callers
(a Delete button is now possible without the rest of the admin classes).
With this, the Settings forms and Model Change forms all now show the
Tested all the Settings forms, various model change forms, and the
integrations/extensions forms (which use their own templates anyway).
Fixed an alignment issue.
Revision 2 (+156 -18)
Checks run (2 succeeded)
Fixed a case where
delete_urlwasn't getting set.
Revision 3 (+158 -18)