Django1.5版本运行时出现'url' requires a non-empty first argument的解决办法,,参考了stackover
Django1.5版本运行时出现'url' requires a non-empty first argument的解决办法,,参考了stackover
参考了stackoverflow里面的一个帖子
I started using Django release 1.5 and got a problem with my old code:<a href="{% url auto.views.viewpost post.slug %}"><h3>{{post.title}}</h3></a>Error: 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs. Docs:One deprecated feature worth noting is the shift to “new-style” url tag. Prior to Django 1.3, syntax like {% url myview %} was interpreted incorrectly (Django considered "myview" to be a literal name of a view, not a template variable named myview). Django 1.3 and above introduced the {% load url from future %} syntax to bring in the corrected behavior where myview was seen as a variable.The upshot of this is that if you are not using {% load url from future %} in your templates, you’ll need to change tags like {% url myview %} to {% url "myview" %}. If you were using {% load url from future %} you can simply remove that line under Django 1.5
大概意思就是说:原来写成:{%url myview%} 这样的语句在1.5以前的版本是可以通过的,
更换到1.5的版本以后要写成:{%url "myview"%}
经过测试的确如此。
相关内容
- python获得本地socket可用的设置信息,pythonsocket,import s
- ACM:A+B问题python代码,acmpython,import strin
- python自定义类并使用的演示示例,python类并,class Perso
- python自定义线程类,python自定义线程,import threa
- python通过MD5验证网站下载文件的有效性,,# -*- coding
- python实现的简单的将字符转换成大写的tcp服务器,pyt
- python循环监控远程端口的代码,python端口代码,#!/usr/b
- python编写自动更换ip工具,python编写ip,#!/usr/bin/e
- python随机生成一个简单的密码代码,python生成代码,im
- python定义一个类实例作为ftp回调方法,python回调,class
评论关闭