Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-03 05:24:41 11月24日 Update

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.

Tags: Version indeed code method can be passed that is post meaning fragment statement time out reference test run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux macOS OPPO Reno Docker