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)

options.diff (1002 bytes ) - added by lsbardel 15 years ago.
widget.diff (1.1 KB ) - added by lsbardel 15 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 by Russell Keith-Magee, 15 years ago

Component: django.contrib.adminForms
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

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.

comment:2 by lsbardel, 15 years ago

True, small modification in forms/widget.py attached

by lsbardel, 15 years ago

Attachment: options.diff added

by lsbardel, 15 years ago

Attachment: widget.diff added

comment:3 by lsbardel, 15 years ago

Owner: changed from nobody to lsbardel
Status: newassigned

comment:4 by Chris Beaven, 14 years ago

Needs tests: set
Patch needs improvement: unset

comment:5 by Luke Plant, 14 years ago

Type: New feature

comment:6 by Luke Plant, 14 years ago

Severity: Normal

comment:7 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:8 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:9 by Sergey Kolosov, 11 years ago

Owner: changed from lsbardel to Sergey Kolosov

comment:10 by Sergey Kolosov, 11 years ago

Resolution: fixed
Status: assignedclosed

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.
Back to Top