Python 谷歌应用引擎:一次发布一组实体
我试图使用表单收集一组数据,但我不知道如何使用POST从表单中获取数据。提前谢谢。该方案: main.pyPython 谷歌应用引擎:一次发布一组实体,python,google-app-engine,templates,Python,Google App Engine,Templates,我试图使用表单收集一组数据,但我不知道如何使用POST从表单中获取数据。提前谢谢。该方案: main.py from google.appengine.ext import db import webapp2 import common class Company(db.Model): name: db.StringProperty() image: db.BlobProperty() url: db.URLPro
from google.appengine.ext import db
import webapp2
import common
class Company(db.Model):
name: db.StringProperty()
image: db.BlobProperty()
url: db.URLProperty()
class MainPage(webapp2.RequestHandler):
def get(self):
common.render(self, 'main.html', {'range': range(10)})
def post(self):
# How to do the following?
for i in range(10):
company = Company()
company.name = self.request.get("name")
company.image = self.request.get("image")
company.url = self.request.get("url")
company.put()
app = webapp2.WSGIApplication([('/', MainPage)], debug=True)
main.html
<form action="/" method="post" enctype="multipart/form-data">
<table>
<tr><th></th><th>Company</th><th>Image</th><th>URL</th></tr>
{% for i in range %}
<tr>
<td>{{ forloop.counter }}: </td>
<td><input type="text" name="name" id="name" /></td>
<td><input type="file" name="image" id="image" /></td>
<td><input type="text" name="url" id="url" /></td>
</tr>
{% endfor %}
</table>
<input type="submit">
</form>
公司图像URL
{范围%中的i的%1}
{{forloop.counter}}:
{%endfor%}
--Tang。getall(键)
应该为您做这件事
# All values for a key: ['a', 'b']
check_values = request.POST.getall('check')
。getall(键)
应该可以帮你完成
# All values for a key: ['a', 'b']
check_values = request.POST.getall('check')