我無法實現這個功能:我導航到了我想要的頁面,但是我看起來似乎在做錯誤的變量。如何將參數從一個視圖傳遞到另一個視圖
views.py:
@view_config(http_cache=1,route_name='hoofdpagina', renderer='templates/hoofdpagina.pt')
def hoofdpagina(request):
page = DBSession.query(MyModel) #.filter_by(id='1').all()
if 'form.submitted' in request.params:
name= request.params['name']
page2=Page(name)
DBSession.add(page2)
return HTTPFound(location=request.route_url('view_page',pagename=name))
return dict(page=page)
@view_config(route_name='diagnose', renderer='templates/diagnose.pt')
def diagnose(request):
return request
kak = ['test1','test2','test3t']
content = {"test1","test2","test3"}
return {'content' :content, 'test' :kak}
hoofdpagina.pt:
<form class="span12" action="/diagnose" method="POST">
<table class="table table-hover">
<thead class="header">
<tr>
<th>D Nr.</th>
<th>Datum</th>
<th>Patient</th>
<th>Prior</th>
</tr>
</thead>
<tr tal:repeat="Page page" >
<td tal:content="Page.dosiernummer"></td>
<td tal:content="Page.dosiernummer"></td>
<td tal:content="Page.datum"></td>
<td tal:content="Page.naamPatient"></td>
<td tal:content="Page.prioriteit"></td>
</tr>
</table>
</form>
<form action="/diagnose" method="post">
<input type="submit" value="Save" name="form.submitted" ></input>
<label name="name">et werkt slet</label>
</form>
我可以顯示網頁的所有變量在我的表。但是當我按下提交按鈕時,我無法將「名稱」標籤的內容獲取到我的診斷頁面。我不知道如何顯示價值。
PS:問題是根據這個帖子:Pyramid app: How can I pass values into my request.route_url?
當您提交表單時,不會發送標籤元素的內容。 – professorsloth 2013-03-04 20:14:42
看來你不僅是新來的金字塔,但對HTML/HTTP也 – bismigalis 2013-03-05 08:31:14
請修復縮進。 – 2013-03-05 08:37:46