尽管进行了更改,但Django-URL未显示页面

这是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.urls


from django.conf.urls import url

from poll.views import *

urlpatterns = [

    url('', index, name='polls_list'),

    url('<int:id>/details/', details, name='polls_details')

]

所以这就是发生的事情,我在index.html上显示了3个问题,单击它们中的任何一个,它将更改为正确的url,但没有打开请求的页面。我该如何解决。请记住,我两天前才刚开始django,所以请原谅我的天真。


慕娘9325324
浏览 223回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python