2
在這個模板,Django模板:如何在模板中的模型中使用字段?
<body><p>You searched for: <strong>{{ first }} {{ last }}</strong></p>
{% if lawyers %}
<p>There are {{ lawyers|length }} schoolmates of <strong>{{ first }} {{ last }}</strong> in the database:</p>
<ul>
{% for lawyer in lawyers %}
<li> {{ lawyer.first }} {{ lawyer.last }} {{ lawyer.firm_name }} {{ lawyer.school }} {{ lawyer.year_graduated }}</li>
{% endfor %}
</ul>
{% else %}
<p><strong>{{ first }} {{ last }}</strong> has no classmates in the database. Try another lawyer.</p>
{% endif %}
我拿起從搜索表單{{ first }}
和{{ last }}
而不是其他的參數,如year_graduated
。
但我希望能夠說:
<p>You searched for: <strong> {{ first }} {{ last }}, class of {{ year_graduated }} </strong> </p>
如何使用lawyer.year_graduated
模板,即使它是不是在搜索的形式?
查看my previous question查看功能。
謝謝。
如果'laywer.year_graduated'在所有結果中都不相同怎麼辦?看起來你暗示'year_graduated'是一個搜索參數? – Seth