Sunday, January 16, 2022

request.POST.getlist('xxx') only has one value in ajax request for many2many

Hi,

Using Django 3.2 and Py 3.9

I have an ajax request which submits multiple values for a field to an UpdateView.

In the request dict body I see both values (in this case, for the pool_list column):

'_body': b"csrfmiddlewaretoken=z...h&...&key=...&expiry_datetime=&overflow=555&pool_list=507&pool_list=499&...

Later in the request dict, I only see one of the values in the _post:
'_post': .... 'pool_list': ['499'],

This means that in request.POST.getlist('pool_list'), I'm only getting one result in the list object.

Any idea why it's only the last value being populated in the getlist?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bf3a5e3b-4e8c-4a73-8647-d494bedbdf90n%40googlegroups.com.

No comments:

Post a Comment