2

I have a simple form using Pyramid and I want to use it as a new or update. I don't particularly want to have to create empty dictionary values for all the fields in my form, I just want it to ignore them without raising an exception.

<div metal:fill-slot="content">
<form method="POST" action="/studentupdate">
    <input name="id" value="${studentid}" type="hidden" />
    Name: <input type="text" name="studentname" value="${studentname}"/><br />
    Exam Score: <input type="text" name="studentexam" value="${studentexam}"/><br />
    Quiz Score: <input type="text" name="studentquiz" value="${studentquiz}"/><br />
    Homework Score: <input type="text" name="studenthomework" value="${studenthw}"/><br />
    <input type="submit" value="Save"/>
</form>
</div>

How can I do this?

Thanks.

4

1 回答 1

0

你可以像这样解决
${studentexam or ''}

% for i in missing_list or []
<li>${i}</li>
% endfor
于 2015-02-04T07:10:48.317 回答