5👍
You should read about QueryDict objects:
>>> q = QueryDict('a=1&a=2&a=3')
>>> q.lists()
[('a', ['1', '2', '3'])]
2👍
Very close. The POST parameters are actually contained in a QueryDict object in the request.
def getids(request):
if request.method == 'POST':
for field in HttpRequest.POST:
// Logic here
- [Django]-Request.data in DRF v/s serializers.data in DRF
- [Django]-Disable django context processor in django-admin pages
- [Django]-Django admin – how to display thumbnail instead of path to file
- [Django]-Python model inheritance and order of model declaration
2👍
If you are submitting lots of identical forms in one page you might find Formsets to be the thing you want.
You can then make one Form for the userid and then repeat it in a Formset. You can then iterate over the formset to read the results.
- [Django]-Django 1054 – Unknown Column in field list
- [Django]-DRF: Always apply default permission class
0👍
You can create the form fields with some prefix you could filter later.
Say you use form fields with names like uid-1, uid-2, … uid-n
Then, when you process the POST you can do:
uids = [POST[x] for x in POST.keys() if x[:3] == 'uid']
That would give you the values of the fields in the POST which start with ‘uid’ in a list.
- [Django]-How to use date__range filter efficiently in django
- [Django]-Django – CreateView – Send a custom Error Message if model form is not valid
0👍
QueryDict
‘s getlist
is what you’re looking for.
From the docs:
>>> q = QueryDict('a=1', mutable=True)
>>> q.update({'a': '2'})
>>> q.getlist('a')
['1', '2']
- [Django]-Django cors headers and server error
- [Django]-Create HTML Mail with inline Image and PDF Attachment
- [Django]-Django – split view.py to small files
- [Django]-Developing an iOS app with a REST api backend (databased backed)
Source:stackexchange.com