2π
β
In the view, you can convert the chartlabels
to a JSON blob, for example with:
import json
def some_view(request):
# ...
context['chartlabels_json'] = json.dumps(context['chartlabels'])
# ...
return render(request, 'some_template.html', context)
In the template, we can then write the blob in an unescaped way:
function convert_strings() {
return {{ chartlabels_json|safe }};
}
A more convenient way is however probably using the django-jsonify
[PyPI] tool, and thus simply pass the charlabel
through the jsonify
filter.
- [Django]-Using two templates from one view
- [Django]-Individual search filters for fields in django-rest-framework
0π
Use the following, for more details on creating the regex for special characters follows this links javascript regex for special characters:
var str = ''CHENNAI LPG RO''
console.log(str.replace(/\&\#39;/g, "'"));
π€Ullas Hunka
- [Django]-Django Admin Remove default save message
- [Django]-Django admin: TypeError on any post request
- [Django]-Easiest way to write a Python program with access to Django database functionality
Source:stackexchange.com