I want to pass an array via Ajax to my Django view, but an error always occurs
stream_or_string = stream_or_string.read ()
AttributeError: 'NoneType' object has no attribute 'read'
$.ajax({
url: 'ajax/',
type: 'POST',
dataType: "json",
data: {disciplina: array_list},
success: function(data) {
//alert("Cadastro realizado com sucesso!");
},
failure: function(data) {
//alert("Ocorreu um erro, realize a operação novamente");
}
}).done(function(data){
//alert(data);
});
view.py
for lista in serializers.deserialize("json", request.POST.get('disciplina')):
idDisciplina = [lista]
If I do something like this
num=request.POST.get('disciplina')
It still receives if I pass only a single value and not an array
Deserialize I used based on what I found, but I did not quite understand its functionality well, can anyone help?