Yeah - I am looping.  I just get one iteration which is the last item even 
though the request body has the same key repeated.

For example, this code only prints one item, whereas for a different form 
elsewhere, it would iterate through all the identical keys:
       print(self.request.__dict__)
      for pool in self.request.POST.getlist('pool_list'):
      print(f"form pool_list item: {pool}")

The main difference to when it works is that this form is submitted via 
ajax; and uses UpdateView. 

On Monday, 17 January 2022 at 01:34:18 UTC Jason wrote:

> https://code.djangoproject.com/ticket/1130
>
> Essentially, this is expected behavior, and previous comment is correct.  
> Need to loop through the items in the list
>
> On Sunday, January 16, 2022 at 5:42:45 PM UTC-5 [email protected] wrote:
>
>> You might want to loop through the list 
>> Example:
>> Lists = request.getlist('item')
>> For list in Lists:
>> .........
>>
>>
>> On Sun, Jan 16, 2022, 9:30 PM Campbell McKilligan <[email protected]> 
>> wrote:
>>
>>> 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 [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/bf3a5e3b-4e8c-4a73-8647-d494bedbdf90n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/bf3a5e3b-4e8c-4a73-8647-d494bedbdf90n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6fc15142-4650-4bac-a3f9-efd411f3813an%40googlegroups.com.

Reply via email to