Reputation: 2441
I have a Kind Tag with property tagName, and in a html, I code like this
{% for tag in tags%}
<input type="checkbox" name="tagName" value={{tag.tagName}}>{{tag.tagName}}
{% endfor%}
Now, In my python file, I try to do this:
tagNames = self.request.get('tagName')
I want a list that contain every choice user choose. But what I got seems not. So.
how can I get a list of user choices using request.get()?
Is there any other ways? I am not familiar with django, I just import gae's template. Can I use gae's template to simplify this question?
Thank you!
Upvotes: 2
Views: 123
Reputation: 90007
Assuming you're using the webapp framework, instead of self.request.get()
, use self.request.get_all('tagName')
, which will return a list of values.
Upvotes: 2
Reputation: 5707
https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict
Looks like QueryDict.getlist(key, default) will get you what you want.
ie. self.request.getlist('tagName')
Upvotes: 2