我在这个问题上纠缠了一段时间,似乎无法修复错误。我已经检查了代码一百次了,但是很明显我遗漏了一些东西。我也安装了我的应用程序
有人能看到我遗漏了什么吗
视图.py
def survey_details(request, id=None):
context = {}
surveys = Survey.objects.get(id=id)
context['survey'] = survey
return render(request, 'surveydetails.html', context)
feedback.url.py
path('details/<int:id>', views.survey_details, name="surveydetails"),
surveys.html
{% extends 'main.html' %}
{% block content%}
<h1>Surveys</h1>
<h2>list of {{title}} </h2>
{% if surveys %}
<ul>
{% for survey in surveys %}
<li>
<a href="{% url 'feedback:surveydetails' %}">{{ survey.title }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>There are no surveys.</p>
{% endif %}
{% endblock %}
surveydetails.html
{% extends 'main.html' %}
{% block content%}
<h1>Surveys</h1>
<h2>Detail page</h2>
<h3>{{question.title}}</h3>
<p>Details page of {{question.title}}</p>
{% endblock %}
这里您没有通过调查id
相关问题 更多 >
编程相关推荐