This error comes when there is a {% url %} tag that is not set up properly - 
like the views.py line highlighted below. So, I suspect you have such a tag say 
tied to a button on the html page, but it isn’t included in this thread.

There’s another error in the code not related to your reverse error - the view 
passes in ‘posts’ as the context name but the template processes ‘post’: 
post.title, post.xxxx, etc. Those have to match in order for the DB values to 
be displayed.

I’d go back through the djangogirls tutorial again and be positive everything 
is typed in correctly. That should fix it.

Jim

On May 23, 2019, at 12:23 PM, cixtus anyanwu 
<sikky...@gmail.com<mailto:sikky...@gmail.com>> wrote:

Still got this erorr. thanks
  File 
"C:\Users\ANYANWU\djangogirls\myvenv\lib\site-packages\django\urls\resolvers.py",
 line 634, in _reverse_with_prefix
    raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'post_details' with keyword 
arguments '{'pk': 3}' not found. 1 pattern(s) tried: ['posts/<int:\\ pk>/$']

On Thursday, May 23, 2019 at 7:29:57 PM UTC+1, subaru_87 wrote:
Below, post is a DB row, not an ID as the URL.py requires.

Change the view as:
return render(request, ‘blog/post_details.html’, {‘pk’: posts[‘id’]})


Jim


On May 23, 2019, at 11:10 AM, Rock N Roll Mühlbacher <chmuhlb...@gmail.com> 
wrote:

Am Donnerstag, 23. Mai 2019 20:06:31 UTC+2 schrieb cixtus anyanwu:
Guys am following the django girls pdf tutoril but am stuck here. Its saying:



django.urls.exceptions.NoReverseMatch: Reverse for 'post_details' with keyword 
arguments '{'pk': 3}' not found. 1 pattern(s) tried: ['posts/<int:\\ pk>/$']
[23/May/2019 18:13:22] "GET / HTTP/1.1" 500 153773
my views.py is below:




from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from .models import Post


# Create your views here.
def post_list(request):
 posts = Post.objects.filter(title__contains='post')
 return render(request, 'blog/post_list.html', {'posts':posts})
def post_details(request, pk):
 posts = get_object_or_404(Post, pk)
 return render(request, 'blog/post_details.html', {'posts': posts})




urls.py




from django.urls import path
from . import views


urlpatterns = [
 path('', views.post_list, name='post_list'),
 path('posts/<int: pk>/', views.post_details, name='post_details')
]




base.html




{% load static %}
<!DOCTYPE html>
<head>
 <title>Django reloaded</title>
 <link rel="stylesheet" type="text/css" href="{% static 'css/blog.css' %}">
</head>
<body>
 <h1>Django Girls Blog </h1>
 {% block content %}
 {% endblock %}
</body>
</html>




post_details.html




{% extends 'blog/base.html' %}
{% block content %}
 {% if post.published_date %}
 <h1>{{post.title}}</h1>
 {% endif %}
 <div>
 <p>{{post.body}}</p>
 <p><b>{{post.published_date}}</b></p>
 </div>
 }
{% endblock %}




I have tried everything i can. Pls help me out guys.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django...@googlegroups.com.
To post to this group, send email to djang...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/92d0fe6d-dc88-4423-9645-402284ac9877%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0a4369bc-2538-4bf7-aaf7-b09be339abec%40googlegroups.com<https://groups.google.com/d/msgid/django-users/0a4369bc-2538-4bf7-aaf7-b09be339abec%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/EB225128-BE1F-47A7-A59A-834978468BBC%40hotmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to