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