我的模板中有这段代码:
{% for email in emails %}
{%if email%}
<input type="checkbox" name="email" value="{{email}}" /> {{email}}<br />
{% endif %}
{% endfor %}
所以模板中的输出是:
email1@sample.com
email2@sample.com
email3@sample.com
...
在我看来,我打印了我的 request.POST 。
print request.POST
print request.POST['email']
for email in request.POST['email']:
print email
我得到了这个输出:
<QueryDict: {u'email': [u'email1@sample.com', u'email2@sample.com', u'email3@sample.com'], ..., u'csrfmiddlewaretoken': [u'05e5bdb542c3be7515b87e8160c347a0', u'05e5bdb542c3be7515b87e8160c347a0']}>
email3@sample.com
e
m
a
i
l
3
@
s
a
m
p
l
e
.
c
o
m
我的问题是,如何在我的视图中获取电子邮件列表?我希望输出是这样的..
email1@sample.com
email2@sample.com
email3@sample.com
...