Django: Error during template rendering

0

I have an error that I can not find:

NoReverseMatch at and Error during template rendering:

link

Link to GitHub

    
asked by Barkalez 13.10.2016 в 22:04
source

2 answers

1

The format you are using for the url is not correct, see:

# definición en urls.py
 url(r'^blog/post/(?P<pk>[0-9]+)/$', views.post_detail, name="post_detail"),
# Uso en post_list.html
<h1><a href="{% url 'post_detail' post.pk %}">{{ post.title }}</a></h1>

It is good practice to add the name attribute to your urls, combining this with the namespace you can identify the urls in a better way.

When you have problems with the urls you can do this in the shell to get more information:

>>> from django.urls import reverse
>>> reverse('post_detail', args=[str(self.id)])
    
answered by 14.10.2016 / 07:08
source
0

You need to add that url to your urls.py file and create the view that responds to that url.

Both should receive the parameter 'pk'

Greetings.

    
answered by 14.10.2016 в 01:13