0

My version of django is 1.6.3

and i learn django start with a project which have a part like this

    #blog_list.html
    <h3><a href="{% url detailblog blog.id %}">{{ blog.caption }}</a></h3>
    #urls.py
    url(r'^blog/(?P<id>\d+)/$', 'blog_show', name='detailblog'),

the process is when i click the one item of the list that blog_list shows to me, it will bring me to blog_show via the a label.

But i got the error message that says:

'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.

I don't know where the location of this answer in the docs.

So help me, tell me the solution of this and the right way to check docs if i come to the same situation like this or worse. Thank you!

MMMMMCCLXXVII
  • 571
  • 1
  • 8
  • 23

1 Answers1

0

You need to put your URL name in quotes:

<h3><a href="{% url 'detailblog' blog.id %}">{{ blog.caption }}</a></h3>

Similar answer here.

Example in docs here. Notice how in the examples, the first argument is in quotes.

Community
  • 1
  • 1
Alex
  • 8,321
  • 1
  • 34
  • 30
  • 'str' object is not callable . why this comes up? Is that any changes should be done with urls.py? – MMMMMCCLXXVII May 19 '14 at 00:10
  • You're probably missing the full path to your view. What imports do you have in urls.py for blog_show? See here: http://stackoverflow.com/questions/4668040/django-str-object-is-not-callable – Alex May 19 '14 at 00:16
  • Yea. I just figured it out. Thank you – MMMMMCCLXXVII May 19 '14 at 00:22