我收到此错误是由URL模板标记引起的:
在模板C:\ Users \不要恐慌\ BitNami DjangoStack项目\ Templates\polls\index.html,第5行的错误
我真的不知道为什么会这样.我尝试删除该行,它工作正常,所以我认为这是唯一一个导致麻烦的人.
(顺便说一句,我在Django 1.4.1)
此外,我已经尝试删除引号并删除第一行及其中的所有组合.帮我?
1 {% load url from future %}
2 {% if latest_poll_list %}
3 <ul>
4 {% for poll in latest_poll_list %}
5 <li><a href="{% url 'polls.views.detail' poll.id %}">{{ poll.question }}</a></li>
6 {% endfor %}
7 </ul>
8 {% else %}
9 <p>No polls are available</p>
10 {% endif %}
Run Code Online (Sandbox Code Playgroud)
如果你喜欢这个 urls.py
app_name = 'polls'
url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
Run Code Online (Sandbox Code Playgroud)
你们不得不像这样做代码
<a href="{% url 'polls:detail' question.id %}">Vote again?</a>
Run Code Online (Sandbox Code Playgroud)
这里的民意调查是名称空间
app_name = 'polls'
在这里是名称空间,所以不要与我们正在注册的应用程序名称混淆 setting.py
归档时间: |
|
查看次数: |
708 次 |
最近记录: |