Django Jquery sorted - how to access POST data

It almost works, but ...

javascript calls django like this:

.sortable({
        connectWith: '.object',
        update: function() {
                        var order = $(this).sortable('serialize');
                $.ajax({
                          type: "POST",
                          data: order,
                          url: "/focus_upd/"
                        });

         .... 

      

And in the focus_upd function, the data comes in fine

POST:<QueryDict: {u'task[]': [u'29', u'20', u'29', u'28']}>,

      

But if I refer to request.POST ['task []'] I get 28

Why is this happening and how can I get the entire list?

+2


source to share


1 answer


Use request.POST.getlist('task[]')



By the way, there is no need to use []

in field names in Django. This is a PHP idiom and just makes life difficult.

+6


source







All Articles