Использую для вывода древовидных комментариев django-mptt.
Каким образом можно перезагрузить\обновить recursetree nodes если я добавляю комментарии с помощью ajax?
ul class="parent">
{% recursetree nodes %}
<li>{{ node.created_date }} {{ node.text }} {{ node.id }}
<form method="POST" class="post-form" action="/create_post/{{node.id}}/" id="post-form-{{ node.id }}">
{% csrf_token %}
<input name="text" type="text" id="{{ node.id }} " placeholder="Comments"></input>
<div id="results"></div> <!-- errors show -->
<input type="submit" value="Post" class="btn btn-primary" >
</form>
{% if not node.is_leaf_node %}
<ul class="children" id="list-{{ node.id }}">
{{ children }}
</ul>
{% endif %}
</li>
{% endrecursetree %}
</ul>
$('.post-form').on('submit', function(e){ e.preventDefault(); $.ajax({ url : $(this).attr('action'), type : "POST", data: $(this).serialize(), success : function(data) { console.log(data); console.log("success"); }, // handle a non-successful response error : function(xhr,errmsg,err) { $('#results').html("<div class='alert-box alert radius' data-alert>Oops! We have encountered an error: "+errmsg+ " <a href='#' class='close'>×</a></div>"); // add the error to the dom console.log(xhr.status + ": " + xhr.responseText); // provide a bit more info about the error to the console } }); });