2017-10-19 94 views
0

我正在使用Google App Engine webapp2框架构建一个简单的网站来统计和收集所有提交的出价。我已经从数据库中读取了每个出价的“Book”。如何为Google App Engine的不同数据值创建不同的表格

目前,对于所有提交的出价,只能显示一个表格。我如何使用jinja2为不同的IssueName创建不同的表格。

例如,如果IssueName = Bond1,则表1收集bond1的所有出价;如果IssueName = Bond2,则表2收集Bond2的所有投标

<table class="table table-striped"> 
       <thead> 
        <tr> 
         <th>IssueName</th> 
         <th>RM Name</th> 
         <th>Customer</th> 
         <th>Price</th> 
         <th>Notional</th> 
         <th>Bid Time</th> 
        </tr> 
       </thead> 
       {% for bid in Book %} 
        <tbody> 
         <tr> 
          <th>{{ bid.IssueName }}</th> 
          <th>{{ bid.RMName }}</th> 
          <th>{{ bid.CustomerName }}</th> 
          <th>{{ bid.BidPrice }}</th> 
          <th>{{ bid.Notional }}</th> 
          <th>{{ bid.BidTime }}</th> 
         </tr> 
        </tbody> 
       {% endfor %} 
       </table> 

回答

0

您有一个名为Book的数据库?或NDB数据存储区内称为Book的种类(表)?我假设你的意思是你有一种叫书的方式。你的请求处理程序看起来像这样吗?

from webapp2_extras import jinja2 

class BidsRequestHandler(webapp2.RequestHandler): 
    def get(self): 
     j = jinja2.Jinja2(self.app) 
     self.response.write(j.render_template('bids.html', **{ 
      'Book': Book.query().fetch(), 
     })) 

为了在你的app.yaml使用你需要这个神社

libraries: 
- name: jinja2 
    version: "2.6" 
相关问题