at views.py :
def changeCat(request, cat_key) :
cat = Category.objects.get(pk=cat_key)
for doc in cat.document_set.all() :
log_changing(doc.title, 'deleted', doc.pk)
cat.delete()
return HttpResponseRedirect(reverse('list'))
at static js file:
$.post('/handbook/changeCat/', {"title" : $("#catTitle").val()})
I want to make $.post function accept simply what view returns, just like it acts after submitting a form, or changing URL with location.href. So I`ve tried to add .success function:
.success(function(data){
//$('html').html(data)//worked bad for me, causing staticfiles issue
location.reload()//it works, but without using response
});
Why I dont like reload() method: when having a 500 error, I don`t receive that cute debug report from django, and only get this error code. Another way is to make hidden form and submit it instead of using $.post, but I hope there is more efficient and correct way.