My purpose is really simple. I want to re-produce the exact same demo from this page in my Django project, so I copied the index.html file to my project.
At the end of the code, there are some Javascript template syntaxes; for example, {% for (var i=0, file; file=o.files[i]; i++) { %}
and Django complains about that: 'for' statements should use the format 'for x in y': for (var i=0, file; file=o.files[i]; i++) {
I think the reason is because Django also uses the same syntax for templates, but I don't quite know how to fix it. Does anyone know how to fix the problem? Thank you in advance.
Django provides the {% verbatim %}
tag. You can use it to ignore the template tokens ({{ {% %} }}
) in a fragment of the template.
Example:
<script id="template-upload" type="text/x-tmpl">
{% verbatim %}
// your template here
{% endverbatim %}
</script>