title: How do I send Django object as parameter in Javascript?
body: <p>So as mention in title, I'm trying to send my Django object to JavaScript so I can massage it in the front end. Let me show you the code (simplified).
  views.py</p>
  <pre><code>def main_page(request):
      contents = Contents.objects.all()
  
      context = {
              'contents' : contents
          }
  
      return render(request, 'main/home.html', context)
  </code></pre>
  <p>template</p>
  <pre><code>    {% for u in all_ans_us_paginated %}
      &lt;div class=&quot;row&quot;&gt;
          &lt;div class=&quot;col&quot;&gt;
              &lt;div class=&quot;&quot; id=&quot;{{u.id}}&quot; onclick=&quot;DetailModal('{{u}}')&quot;&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      {% endfor %}
  
  ...
  
  &lt;script&gt;
      function DetailModal(u) {
          console.log('{{u.author}}');
          console.log('{{u.body}}');
      }
  &lt;/script&gt;
  </code></pre>
  <p>My intention is to show a modal when the click event is triggered. But putting the modal part aside, I can't pass data as parameter to JavaScript.<br><br>
  *I don't want to make any changes in the python code. Is it possible to do it only with HTML and JavaScript? <br>
  **<code>JSON.parse(u)</code> won't work, because <code>u</code> is string.</p>