如何在django 2模板中查询主键对象
查询数据库后,我的模板不会显示任何内容。请找到附件我的模型,网址,模板 模型 观点 模板索引 此模板不会在浏览器上显示任何数据如何在django 2模板中查询主键对象,django,django-templates,django-views,Django,Django Templates,Django Views,查询数据库后,我的模板不会显示任何内容。请找到附件我的模型,网址,模板 模型 观点 模板索引 此模板不会在浏览器上显示任何数据 {% if goals %} <h1>{{ object_list.fullname }}</h1> <ul> {% for goal in goals.scrumygoals_set.all %} <li><a href="{% url 'greyscrumy:index' g
{% if goals %}
<h1>{{ object_list.fullname }}</h1>
<ul>
{% for goal in goals.scrumygoals_set.all %}
<li><a href="{% url 'greyscrumy:index' goal.id %}">{{ goal.goal_type }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No goals are available.</p>
{% endif %}
像这样:
{% for goal in goals %}
<h1>{{ goal.user_id.fullname }}</h1>
<p>{{ goal.goal_type }}</p>
<p>{{ goal.goal_description }}</p>
<p>{{ goal.date_created }}</p>
<p>{{ goal.date_updated }}</p>
<p>{{ goal.user_id.role }}</p>
<p>{{ goal.status_id.status }}</p>
{% endfor %}
{%用于目标中的目标%}
{{goal.user_id.fullname}
{{goal.goal_type}
{{goal.goal_description}}
{{goal.date_created}
{{goal.date_updated}
{{goal.user_id.role}
{{goal.status_id.status}
{%endfor%}
{% if goals %}
<h1>{{ object_list.fullname }}</h1>
<ul>
{% for goal in goals.scrumygoals_set.all %}
<li><a href="{% url 'greyscrumy:index' goal.id %}">{{ goal.goal_type }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No goals are available.</p>
{% endif %}
{% for goal in goals %}
{% for innergoal in goals %}
{{ innergoal.id }} {{ innergoal.goal_description }}
{% endfor %}
{% endfor %}
{% for goal in goals %}
<h1>{{ goal.user_id.fullname }}</h1>
<p>{{ goal.goal_type }}</p>
<p>{{ goal.goal_description }}</p>
<p>{{ goal.date_created }}</p>
<p>{{ goal.date_updated }}</p>
<p>{{ goal.user_id.role }}</p>
<p>{{ goal.status_id.status }}</p>
{% endfor %}