开发者

retrieving list items from request.POST in django/python

In my request.POST i am getting a query dictionary , one of the items in this dictionary is a list with multiple items (pass_id) eg.

I want to retrieve each开发者_JAVA百科 of the values in pass_id and store in a new list. Can you suggest the code for this?


http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict.getlist

request.POST.getlist('pass_id')


Try following django >1.4 and use

request.POST.dict()


If you're in a form, a better approach is:

posted = self.fields[field_name].widget.value_from_datadict(
    self.data, self.files, self.add_prefix(field_name)
)

This will return a list if appropriate for the field, and apply cleaning, prefixing, etc. (I copied this from Django form form.cleaned_data method.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜