I was expecting my POST data to end up with a 17 element list after
using getlist(), but I end up with all the data in a single element.
I've tried to reformat the data before it's sent by removing the '[]
and different things', but I still end up with a single element.

This is my first Django and first Python project. Am I missing
something, or misunderstanding how th
e QueryDict works?


My setup is:

OSX 10.4.11
Python 2.5.1
Django version 0.97-pre-SVN-7124

Using the following to send a list to my view

template:
{% if rider_list %}
  <ol id="sortedriders">
    {% for r in rider_list %}
      <li id="pick_{{ r.id }}">
        {{ r.rider.number|stringformat:" 3d" }}
{{ r.rider.first_name }} {{ r.rider.last_name }}
      </li>
    {% endfor %}
  </ol>
    {% else %}
      <p>No Riders to list</p>
{% endif %}


  Sortable.create("sortedriders", {
    onUpdate: function() {
      new Ajax.Request("sort/", {
        method: "post", asynchronous:true,
        parameters: { data: Sortable.serialize("sortedriders") }
      });
    }
  });


views.py
def sort(request):

 if request.method == 'POST':

    data  = request.POST.getlist("data")
    logging.debug(repr(data))
    logging.debug(data[0])

    # everything else deleted out of frustration :)

  return HttpResponse('OK')



output:
DEBUG:root:
[u'sortedriders[]=22&sortedriders[]=21&sortedriders[]=25&sortedriders[]=26&sortedriders[]=23&sortedriders[]=27&sortedriders[]=28&sortedriders[]=24&sortedriders[]=29&sortedriders[]=30&sortedriders[]=31&sortedriders[]=32&sortedriders[]=33&sortedriders[]=34&sortedriders[]=35&sortedriders[]=36&sortedriders[]=37']
DEBUG:root:sortedriders[]=22&sortedriders[]=21&sortedriders[]=25&sortedriders[]=26&sortedriders[]=23&sortedriders[]=27&sortedriders[]=28&sortedriders[]=24&sortedriders[]=29&sortedriders[]=30&sortedriders[]=31&sortedriders[]=32&sortedriders[]=33&sortedriders[]=34&sortedriders[]=35&sortedriders[]=36&sortedriders[]=37
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to