Using uploaded images in templates

Hello,

I am new to Django and I am creating a blog app. Now I want to write some HTML in my blog post content field which is text field in order add some headings and images.

I also add an Image model inline to the post model in the admin page and I try to write it like this but it just prints the HTML and doesn’t actually print the image.

Please check the screenshot.

What should I do here?

I have fixed it by using the safe filter in the template and using URL directly instead of trying to get it through image file path.

If you share the part of your template that was causing the problems, someone might be able to see how you can do it without using the safe filter.

It was just {{ post.body.content }}

Did you try: {{ post.content | safe }}?

Also consider to show your code to better understand what is going on here.

Yes I tried the safe filter and I also modified the generic detail view to render the post content html myself and now it works as I wanted it to work I just wondered if there was a django built-in way to do it instead of me manually using beautiful soup but that is fine for me.

Here are the screenshots of admin panel, view code and template code.

Please paste your code in code brackets and not images.

Oh sorry. How do I do that? I am new here.

When you edit a post here use the ‘</>’ symbol like this

oh right like Hello

If you surround blocks of code with three backticks (```) on their own line, then it will be formatted correctly and, I think, automatically syntax highlighted.