title: Encoding to utf-8 binary data in Flask-Jinja2 while for-looping
body: <p>I am using for loop in jinja2 template to extract data from database.</p>
  <p><code>{{p.author.profile_picture}}</code> in my database is saved as binary data. I have to encode it in utf-8 format to see the image on the website. Can I change it somehow during loop? Or is there any easy way to pass it back to my python backend? I am using Flask.</p>
  <pre class="lang-py prettyprint-override"><code>    {% for p in posts %}
      &lt;div&gt;
        &lt;img src=&quot;data:image/jpg;base64,{{p.author.profile_picture}}&quot;&gt;
        &lt;h3&gt;{{ p.author.username }}&lt;/h3&gt;
        &lt;h2&gt;{{ p.title }}&lt;/h2&gt;
        {{ p.text | safe }}
      &lt;/div&gt;
      {% endfor %}
      
      @app.route('/')
      def home():
          posts = Post.query.order_by(Post.date.desc())
          return render_template('home.html', posts=posts)
  </code></pre>