Opened 6 years ago

Closed 8 months ago

#13875 closed New feature (fixed)

submit_row templatetag should pass whole context

Reported by: drul Owned by: Alexander Herrmann
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: tomasz.kloc@…, Andy Baker, benatkin, vvangelovski@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description

django submit_row inclusion tag doesn't pass extra_context from ModelAdmin.(add|change|..)_view to submit_row.html template. Because of that, i cannot add extra button to submit row (i.e. print invoice). this tag should pass whole context to the template

Attachments (3)

admin_modify.py.diff (878 bytes) - added by drul 6 years ago.
patch
13875_submit_row_whole_context.diff (1.3 KB) - added by Julien Phalip 6 years ago.
13875-r16357.diff (1.2 KB) - added by Alexander Herrmann 5 years ago.

Download all attachments as: .zip

Change History (24)

Changed 6 years ago by drul

Attachment: admin_modify.py.diff added

patch

comment:1 Changed 6 years ago by drul

Cc: tomasz.kloc@… added
Has patch: set
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 6 years ago by dmoisset

Triage Stage: UnreviewedAccepted

comment:3 Changed 6 years ago by Ramiro Morales

See also #11974.

Changed 6 years ago by Julien Phalip

comment:4 Changed 6 years ago by Julien Phalip

milestone: 1.3

This is technically a new feature and therefore I'm removing the 1.3 milestone since we're in beta stage right now. Passing the whole context to the template is a good thing, however the general context should not be modified with the {% submit_row %}'s specific variables (as done in drul's patch). Instead a disposable specific new context should be passed through (as done in my suggested patch).

comment:5 Changed 5 years ago by Graham King

Severity: Normal
Type: New feature

comment:6 Changed 5 years ago by Andy Baker

Cc: Andy Baker added
Easy pickings: unset

comment:7 Changed 5 years ago by patchhammer

Patch needs improvement: set

13875_submit_row_whole_context.diff fails to apply cleanly on to trunk

comment:8 Changed 5 years ago by Julien Phalip

UI/UX: set

comment:9 Changed 5 years ago by Alexander Herrmann

Owner: changed from nobody to Alexander Herrmann
Status: newassigned

Changed 5 years ago by Alexander Herrmann

Attachment: 13875-r16357.diff added

comment:10 Changed 5 years ago by Alexander Herrmann

Patch needs improvement: unset

fixed patch for current source

comment:11 Changed 5 years ago by Julien Phalip

Needs tests: set

comment:12 Changed 5 years ago by benatkin

Another thing: it would be nice if I could individually override the button row in a template. In change_form.html there's:

{% submit_row %}

If it got changed to something like:

{% block submit_button_row %}
    {% submit_row %}
{% endblock %}

I could override it individually. In fact, I copied the entire change_form.html from django/contrib/templates to my own template directory and made this modification for my project.

comment:13 Changed 5 years ago by benatkin

Cc: benatkin added

I realize I could also override the template tag, but this makes it easier to modify one change form without having to worry about messing up the other change forms.

comment:14 Changed 5 years ago by Vasil Vangelovski

Cc: vvangelovski@… added

comment:15 Changed 5 years ago by Ramiro Morales

In [16956]:

Fixed #9460 -- Added template blocks for submit buttons rows in admin app model add/change views.

This allows for easier customization. Thanks kosmik for report and patch.

Refs #13875.

comment:16 Changed 8 months ago by Federico Capoano

it is not clear if the patch needs improvements or not.

comment:17 Changed 8 months ago by Federico Capoano

Easy pickings: set
Patch needs improvement: set
Version: 1.2master

comment:18 Changed 8 months ago by Federico Capoano

Summary: cannot customize admin submit_rowsubmit_row templatetag should pass whole context

comment:19 Changed 8 months ago by Federico Capoano

Just opened PR https://github.com/django/django/pull/6078.

A more paranoid test could be written, like creating a custom app with an admin that extends the context, loads a modified version of the subimt_row template and check the extended context is available in the template. But I think all the complexity needed wouldn't add much value.

Federico

comment:20 Changed 8 months ago by Tim Graham

Needs tests: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:21 Changed 8 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In e972a7d0:

Fixed #13875 -- Made admin's submit_row template tag pass whole context.

Note: See TracTickets for help on using tickets.
Back to Top