Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

& # 39 requires a non-empty first argument. The syntax changed in Django 1.5, see the docs

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

The solution to the occurrence of 'url' requires a non-empty first argument' at Django runtime:

Refer to a post in stackoverflow

I started using Django release 1.5 and got a problem with my old code: `post`.`title`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. This code snippet is from: http://www.sharejs.com/codes/python/7007

A statement originally written as: {% url myview%} can be passed in versions prior to 1.5

After changing to version 1.5, write as follows: {% url "myview"%}

After testing, it is indeed true.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report