title: Django include template using Javascript
body: <p>I came from a Rails background thus the question may seem stupid. 
  In Rails, when we create a Ajax request, then we can update a view by rendering a partial using the javascript selector like the following:</p>
  
  <pre><code>$("#dashboardEmails").html("&lt;%=j render partial: 'emails', locals: {emails: @emails} %&gt;");
  </code></pre>
  
  <p>How can I do that in Django template? I've tried the following:</p>
  
  <pre><code>$.ajax({
          type: frm.attr('method'),
          url: frm.attr('action'),
          data: frm.serialize() + "&amp;submit=connect",
          success: function (data) {
            if(data['tables'].length &gt; 0){
              $('#data-connection-info').html("{% include 'projects/connection_info.html' with data='"data"' %}");
            }
            console.log(data);
          },
          error: function (data) {
            console.log("Error");
          }
  });
  </code></pre>
  
  <p>Here, I want to update the view with a template <code>projects/connection_info.html</code>, also passing a javascript variable (<strong>data</strong>) to the template using <code>with</code>. But it is not working. </p>
  
  <p>Any idea how can I achieve that?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I passed the template from the view like:</p>
  
  <pre><code>template = render_to_string('projects/connection_info.html', json_data)
  return HttpResponse(json.dumps(template), content_type='application/json')
  </code></pre>
  
  <p>Then in the ajax success function updates the DOM:</p>
  
  <pre><code>success: function (data) {
            $('#data-connection-info').html(data);
   }
  </code></pre>
  
  <p>In this way the problem is solved. :) </p>