简体   繁体   中英

Why does this happen in my template for Django?

simple%20minds is displayed when do this:

{{ rec.artist_name }}

How do I remove the %20...and make it spaces?

When I put | safe as a fitler, the error is:

Could not parse the remainder: ' | safe' from 'active.artist_name | safe'

Thanks.

I think you're being hit by Django's relatively-new autoescaping. What happens if you do

{{ rec.artist_name | safe }}

to avid the value being autoescaped?

Try removing the space between the rec.artist_name and the |. So you should have this:

{{ rec.artist_name|safe }}

That'll fix the autoescaping, but I think the other commentors are correct in saying that you're storing the %20 into the db. So you'll probably have to fix it on that end of things.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM