django

简介: 查看django版本: F:\>python -c "import django;print django.VERSION;print django.get_version();" (1, 8, 0, 'final', 0) 1.


查看django版本:

F:\>python -c "import django;print django.VERSION;print django.get_version();"
(1, 8, 0, 'final', 0)
1.8

F:\>
F:\>python
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on wi
n32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 8, 0, 'final', 0)
>>> django.get_version()
'1.8'
>>>

 

u'polls' is not a registered namespace
Request Method:    GET
Request URL:    http://127.0.0.1:8000/polls/2/
Django Version:    1.8
Exception Type:    NoReverseMatch
Exception Value:    
u'polls' is not a registered namespace
Exception Location:    C:\Python27\lib\site-packages\django\core\urlresolvers.py in reverse, line 575
Python Executable:    C:\Python27\python.exe
Python Version:    2.7.10
In template F:\python\tcsite\polls\templates\polls\detail.html, error at line 13
u'polls' is not a registered namespace
3    <html>
4    <head>
5        <title>detail:{{ question }}</title>
6    </head>
7    <body>
8    
9    <h1>{{ question.question_text }}</h1>
10    
11    {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
12    
13    
      <form action="
      {% url 'polls:vote' question.id %}
      " method="post">

      
14        {% csrf_token %}
15        {% for choice in question.choice_set.all %}
16            <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}"/>
17            <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br/>
18        {% endfor %}
19        <input type="submit" value="Vote"/>
20    </form>
21    
22    <hr/>
23    <!--

解决办法:
将F:\python\tcsite\urls.py中

url(r'^polls/', include('polls.urls')),
改为
url(r'^polls/', include('polls.urls', namespace="polls")),

在项目/url.py中的include参数增加namespace="polls"后,上述问题解决,但在打开http://127.0.0.1:8000/polls/时报错:

Reverse for 'detail' with arguments '(2,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Request Method:    GET
Request URL:    http://127.0.0.1:8000/polls/
Django Version:    1.8.5
Exception Type:    NoReverseMatch
Exception Value:    
Reverse for 'detail' with arguments '(2,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Exception Location:    D:\Python27\lib\site-packages\django\core\urlresolvers.py in _reverse_with_prefix, line 495
Python Executable:    D:\Python27\python.exe
Python Version:    2.7.8
Error during template rendering

In template F:\python\tcsite\polls\templates\polls\index.html, error at line 11
Reverse for 'detail' with arguments '(2,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
1    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2            "http://www.w3.org/TR/html4/loose.dtd">
3    <html>
4    <head>
5        <title>polls</title>
6    </head>
7    <body>
8    {% if latest_question_list %}
9        <ul>
10            {% for question in latest_question_list %}
11    
                  <li><a href="
      {% url 'detail' question.id %}
      ">{{ question.question_text }}</a></li>

      
12            {% endfor %}
13        </ul>
14    {% else %}
15        <p>No polls are available.</p>
16    {% endif %}
17    </body>
18    </html>

解决办法:
将第index.html第11行

<li><a href="{% url 'detail' question.id %}">{{ question.question_text }}</a></li>
改为:
<li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>

http://stackoverflow.com/questions/33151816/noreversematch-at-polls-django-tutorial

 

相关文章
|
算法 计算机视觉
【MATLAB 】 EWT 信号分解+希尔伯特黄变换+边际谱算法
【MATLAB 】 EWT 信号分解+希尔伯特黄变换+边际谱算法
411 0
阿里云域名收费标准(com/cn等不同后缀价格表)
阿里云域名多少钱一年?阿里云域名价格?域名后缀不同新注册价格、续费价格及转入价格也不同
|
监控 网络协议 安全
2023年最新整理的中兴设备命令合集,网络工程师收藏!
2023年最新整理的中兴设备命令合集,网络工程师收藏!
1086 0
|
Ubuntu Linux Windows
ubuntu16.04安装MATLAB R2017b步骤详解(附完整文件包)
ubuntu16.04安装MATLAB R2017b步骤详解(附完整文件包)
910 0
ubuntu16.04安装MATLAB R2017b步骤详解(附完整文件包)
三角函数中的正弦、余弦、正切、余切、正割、余割函数性质及常用公式
三角函数中的正弦、余弦、正切、余切、正割、余割函数性质及常用公式
1412 0
三角函数中的正弦、余弦、正切、余切、正割、余割函数性质及常用公式
|
安全
【实用工具】如何录制电脑屏幕gif动图?
【实用工具】如何录制电脑屏幕gif动图?
564 0
【实用工具】如何录制电脑屏幕gif动图?
|
测试技术 Python
免费的python学习网站推荐
免费的python学习网站推荐
685 0
|
存储 算法 NoSQL
【数据库系列】什么是列式存储和行式存储
列式存储:每一列单独存放,数据即是索引。只访问涉及得列,如果我们想访问单独一列(比如NAME)会相当迅捷。一行数据包含一个列或者多个列,每个列一单独一个cell来存储数据。行式存储: 把一行数据作为一个整体来存储。学习:https://blog.csdn.net/qq_43543789/article/details/108662140。......
1058 0
【数据库系列】什么是列式存储和行式存储
|
Java 数据库 容器
2018年阿里巴巴重要开源项目汇总(资料参考)
云栖社区特在2018年年末,将阿里巴巴的一些重要的开源项目进行整理,希望对大家有所帮助。
|
人工智能 负载均衡 算法
5G如何保障服务质量?
为什么在人多的时候,我的速率会降低,时延会增加呢?
5G如何保障服务质量?