这是index.html{% extends 'base.html' %}{% block content %}<h1>list of {{title}}</h1>{% if questions %} <ul> {% for question in questions %} <li> <a href="/polls/{{question.id}}/details/"> {{question.title}}</a> </li> {% endfor %} </ul> {% else %} <p>there is a no question available</p> {% endif %}{% endblock %}details.html{% extends 'base.html' %}{% block content %}<H2>Details Page</H2><h3>{{question.title}}</h3>{% for choice in question.choices %}<p>{{choice.text}}({{choice.votes}})</p>{% empty %}<p>There is no choice available for this Question</p>{% endfor %}<p>Poll is created by {{question.created_by.first_name}}</p>{% endblock %}这是base.html{%load static%}<html><head> <meta charset="UTF-8"> <title>WebPage</title> <link rel="stylesheet" href="(%static 'css/custom.css'%)"></head><body><h1>Welcome to My Page</h1>{% block content %}{% endblock %}</body></html>还有poll.urlsfrom django.conf.urls import urlfrom poll.views import *urlpatterns = [ url('', index, name='polls_list'), url('<int:id>/details/', details, name='polls_details')]所以这就是发生的事情,我在index.html上显示了3个问题,单击它们中的任何一个,它将更改为正确的url,但没有打开请求的页面。我该如何解决。请记住,我两天前才刚开始django,所以请原谅我的天真。
添加回答
举报
0/150
提交
取消