0

I want to synchronize my dropzone allowfiles templates with my python upload config allowed files. I can get jinja to spit out my UPLOAD_EXTENSIONS with config.UPLOAD_EXTENSIONS but I can not figure out how to format it into a string that can be used in my javascript allowdfiles format. See below for what I get vs what I want.

jinja html template

<script>
    let allowed_files = "{{ config.UPLOAD_EXTENSIONS }}";
    console.log(allowed_files)
</script>

Console Log

[&#39;.jpg&#39;, &#39;.png&#39;, &#39;.gif&#39;]

What I want is this string

.jpg,.png,.gif

1 Answer 1

1

You should use safe filter like this:

<script>
    let allowed_files = "{{ config.UPLOAD_EXTENSIONS|safe }}";
    console.log(allowed_files)
</script>

but it returns a result like this:

[".jpg", ".png", ".gif"]

If you want the exact use: console.log(allowed_files.join())

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.