Hello,
I have a seemingly straight forward and likely common issue. But there is no obvious way that I am seeing to make it work.
I have a Blog model with a text field called entry. I want to put something like
<img src="{{ MEDIA_URL }}/images/my_image.jpg">
into the blog post. So Blog.entry would contain it. Then I use the template to display my blog post like
{% for post in posts %} <p>{{ post.entry }}</p> {% endfor %}
But the template does not process {{ MEDIA_URL }}. It just sees it as a string and prints it exactly as passed in.
How do I get the template to treat {{ }} in my entry as a variable? How can I get that value substituted? I have used a custom template filter in the past. But this has got to be a very common use case. It seems like there would be some built in django way to get this to work?
Thanks,
Dennis
-- I have a seemingly straight forward and likely common issue. But there is no obvious way that I am seeing to make it work.
I have a Blog model with a text field called entry. I want to put something like
<img src="{{ MEDIA_URL }}/images/my_image.jpg">
into the blog post. So Blog.entry would contain it. Then I use the template to display my blog post like
{% for post in posts %} <p>{{ post.entry }}</p> {% endfor %}
But the template does not process {{ MEDIA_URL }}. It just sees it as a string and prints it exactly as passed in.
How do I get the template to treat {{ }} in my entry as a variable? How can I get that value substituted? I have used a custom template filter in the past. But this has got to be a very common use case. It seems like there would be some built in django way to get this to work?
Thanks,
Dennis
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/60b7bdc9-f396-4ffd-b4ff-10a7dd5931c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment