views:

448

answers:

1

Nearly have this working but...

the 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 arrives ok

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 whole list?

+2  A: 

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

By the way, there's no need to use [] in field names in Django. This is a PHP idiom, and just makes life more complicated.

Daniel Roseman
That's perfect. The javascript is passing the post data it in like that. Probably some way to change it, but it's working!Thanks.