Answer the question
In order to leave comments, you need to log in
Why doesn't render fire in views.py django when passing ajax request?
On the html page there is an input and ajax to it, which passes some value to views.py
<input type="text" name="zayavka_number" required="" id="id_zayavka_number" placeholder="введите номер заявки для отображения" onchange="sortComplectTable(value)">
<script> function sortComplectTable(value) {
$.ajax({
url: "/sort_complect_table",
type: "POST",
dataType: "json",
data: {
value: value,
csrfmiddlewaretoken: '{{ csrf_token }}'
},
});
}</script>
def sort_complect_table(request):
sort_zayavka = request.POST.get('value')
print(value)
sort_compl_table = ComplectTable.objects.filter(zayavka_number=sort_zayavka)
return render(request, 'journal/komplekt_table.html', {"full_compl_table" : sort_compl_table})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question