Add an encoder parameter to django.utils.html.json_script().
I have a use case where I want to customize the JSON encoding of some values to output to the template layer. It looks like django.utils.html.json_script is a good utility for that, however the JSON encoder is hardcoded to DjangoJSONEncoder. I think it would be nice to be able to pass a custom encoder class.
By the way, django.utils.html.json_script is not documented (only its template filter counterpart is), would it be a good thing to add to the docs?
Change History
(8)
| Summary: |
Add an encoder parameter to django.utils.html.json_script → Add an encoder parameter to django.utils.html.json_script().
|
| Triage Stage: |
Unreviewed → Accepted
|
| Owner: |
changed from nobody to Hrushikesh Vaidya
|
| Status: |
new → assigned
|
| Has patch: |
set
|
| Needs documentation: |
set
|
| Needs tests: |
set
|
| Needs documentation: |
unset
|
| Needs tests: |
unset
|
| Triage Stage: |
Accepted → Ready for checkin
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
Sounds good, and yes, we should document
django.utils.html.json_script().