1👍
✅
Why not loop through the entire list and then do regex on each item’s name? QueryDict.lists()
or QueryDict.values()
allows you to get all of it and then loop through that.
QueryDict.lists()
Like items(), except it includes all values, as a list, for each member of the dictionary.
For example:
>>> q = QueryDict('a=1&a=2&a=3')
>>> q.lists()
[(u'a', [u'1', u'2', u'3'])]
Link: http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict
1👍
Just iterate over the keys and keep those you want
>>> post = {'item_id_1': 1, 'item_id_2': 2, 'item_id_3': 3, 'noitem': 0}
>>> dict([(k, v) for k, v in post.items() if k[:8] == 'item_id_'])
{'item_id_3': 3, 'item_id_2': 2, 'item_id_1': 1}
- [Answered ]-Revelants queries suggestion for autocomplete with Solr
- [Answered ]-Serving protected files with Django and Nginx X-accel-redirect
- [Answered ]-Controlling a Twisted Server from Django
- [Answered ]-Python.exe crashes when I run manage.py runserver
- [Answered ]-Django's built in web server: Usage and Reliability Concerns
Source:stackexchange.com