2

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.

  1. how can I get a list of user choices using request.get()?

  2. 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!

4

2 に答える 2

2

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')

于 2012-05-05T09:48:45.523 に答える
2

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.

于 2012-05-06T18:37:51.090 に答える