Opened 15 years ago
Closed 11 years ago
#13150 closed New feature (fixed)
Replace make_safe(media) with media in ModelAdmin context dictionary
Reported by: | lsbardel | Owned by: | Sergey Kolosov |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | media |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently, the media object is converted to safe string in both add_view
and change_view
methods when added to the context dictionary
while in changelist_view
is not (the correct approach).
Converting media to string means you cannot split css from js in
templates. What I'd like to do is
<head> ... {% for css in media.render_css %} {{ css|safe }}{% endfor %} </head> <body> ... {% for js in media.render_js %} {{ js|safe }}{% endfor %} </body>
A two lines modification.
Attachments (2)
Change History (12)
comment:1 by , 15 years ago
Component: | django.contrib.admin → Forms |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
by , 15 years ago
Attachment: | options.diff added |
---|
by , 15 years ago
Attachment: | widget.diff added |
---|
comment:3 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 14 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | unset |
comment:5 by , 14 years ago
Type: | → New feature |
---|
comment:6 by , 14 years ago
Severity: | → Normal |
---|
comment:9 by , 11 years ago
Owner: | changed from | to
---|
comment:10 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
It had been already fixed a while ago:
https://github.com/django/django/commit/a92e7f37c4ae84b6b8d8016cc6783211e9047219
The patch above is not needed anymore.
Note:
See TracTickets
for help on using tickets.
Valid point (and fix), but you shouldn't need to do the |safe yourself. Django is generating the HTML; it should be considered safe. The contents of render_css and render_js should be marked safe internally ready for rendering.