0

My model name is cat

I am fetching this in html template using safe just like

{{cat.languages|safe}}

See my model enter image description here

Here is url in html

enter image description here

Tariq Ahmed
  • 471
  • 3
  • 14
  • 1
    That's not going to work. You're trying to render template logic from inside a string that is saved in the database - Django will not process that string as a template, it will just render it as-is. This is quite risky to do (what happens if the string gets modified in ways that you don't expect?). I think you need to reconsider how you're storing your data and think about storing it in a more structured way, so that you're not trying to store template logic in the database. – solarissmoke Mar 15 '22 at 04:43
  • 1
    If you really do want to do this, you would have to write a custom template filter to which you pass the string, that then renders it as a template (see [this question](https://stackoverflow.com/questions/2259743/how-to-make-django-template-engine-to-render-in-memory-templates) for how to do that). It's very risky to do this unless you have absolute control of what is stored in the string. – solarissmoke Mar 15 '22 at 04:46
  • @solarissmoke could you elaborate what do you mean by ```custom template filter``` and what do you mean by ```what happens if the string gets modified in ways that you don't expect?``` and what do you mean by ```This is quite risky to do``` Please elaborate these in detail answer, i'll will accept your answer. – Tariq Ahmed Mar 15 '22 at 08:31

0 Answers0