Search code examples
pythonhtmljinja2

Jinja2 how to escape character '?' in html template file?


I already put safe filter. enter image description here In my html output, I expected to receive enter image description here But I keep receiving this instead enter image description here

Why it keeps happening? I am totally new. Please teach me how can I remove that %3F by replacing it with '?' character ?


Solution

  • Assuming you are using Windows, the question mark character is forbidden in file names, this is why the url_for() function encodes it. However you don't need to include this suffix at all in url_for(), it expects a real file path. You can put this suffix after the url_for() calling e.g.:

    href="{{ url_for('static', filename='assets/fonts/wolmart.woff') }}?png09e"