django1.8 出现NoReverseMatch错误怎么解决?,,django1.8 出现
django1.8 出现NoReverseMatch错误怎么解决?,,django1.8 出现
django1.8 出现NoReverseMatch错误怎么解决?环境: python 3.4.3 django-1.8.2
在展示详细内容时出现这个异常:
NoReverseMatch at /Reverse for 'detail' with arguments '()' and keyword arguments '{'pk_id': 2}' not found. 1 pattern(s) tried: ['$qs/(?P<pk_id>[0-9]+)/$']
其中有关的文件如下:
index.html
{% for item in post_latest %} <h1 class="title transition"><a href="{% url 'detail' pk_id=item.pk %}">{{item.brief}}</a></h1>{% endfor %}
urls.py
urlpatterns = [ url(r'^$', views.IndexView.as_view(), name='index'), url(r'^qs/(?P<pk_id>[0-9]+)/$', views.detail, name='detail'), ]
views.py
def detail(request, pk_id): detail_qs = get_object_or_404(Qs, pk=pk_id) return render(request, 'qs/node/detail.html', {'detail': detail_qs})
当把index.html中的内容改成如下时,则没有这个异常
<h1 class="title transition"><a href="qs/{{item.id}}/">{{item.brief}}</a></h1>
但是按照django的规范中,还是最开始的写法符合,但是却一直报异常,google未果,所以求帮助
编橙之家文章,
相关内容
- django读取日志并写入db数据库中,怎么样用页面展示出
- python3 类型Type str doesn't support the buffer API?,python3buffe
- Tornado里面self.write("hello")出现"Broken pipe Error"怎么
- requests爬取代理网站ip验证,登陆ip网站查询ip不变的原
- 用python将序列化之后的 json 存储在 mysql 中并且对于开发
- 编程语言的选择: Why choose Ruby or Python over PHP for web dev
- Django Web开发里面的url的重定向问题,比如这个abc.com/
- CentOS系统Python的版本太low了,该怎么升级呢》,centos
- Scrapy pipeline数据模块出现问题的解决,scrapypipeline,Scr
- django admin管理部分是否在一个页面inline外键的外键呢?
评论关闭