Django release 1.5: 'url' requires a non-empty first argument. The syntax changed in Django 1.5 Django release 1.5: 'url' requires a non-empty first argument. The syntax changed in Django 1.5 django django

Django release 1.5: 'url' requires a non-empty first argument. The syntax changed in Django 1.5


I really hate doing all this junk by hand, so I wrote a sed script to do it for me. Make sure you have a backup first, then run this in your templates directory:

find . -type f -print0 | xargs -0 sed -i 's/{% url \([^" >][^ >]*\)/{% url "\1"/g'

It'll go through all of your template files and replace this:

{% url something.else foo bar %}

with this

{% url "something.else" foo bar %}

Be careful, I was a little lazy with this, it might break on some constructs. It's still going to be easier looking for errors in a diff than doing it by hand, though.


To exclude folder of .git and to avoid error's MacOS added empty quotes to option -i ''. Example:

find . -path '*/.git*' -prune -o -type f -print0 | xargs -0 sed -i '' 's/ url \([^" >][^ >]*\)/ url "\1"/g'

But I like this approach (MacOS):

grep '{% url' -lrZ . | xargs -0 sed -i '' 's/ url \([^" >][^ >]*\)/ url "\1"/g'


Firstly, you were correct to use single quotes for the view name, i.e. 'auto.views.view_post'.

Now, temporarily remove the url tag, and check that {{ post }} and {{ post.slug }} give you the values you expect. The error message arguments '('',)' suggests that post.slug is the problem.