작동하지 않을 수 있습니다. 원하는 페이지로 이동하지만 보이는 변수에 문제가 있습니다.하나의보기에서 다른보기로 매개 변수를 전달하는 방법
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
피라미드에 새로 온 것은 아니지만 HTML/HTTP도 마찬가지입니다. – bismigalis
들여 쓰기를 수정하십시오. –