I am getting this error plz help me out of this.

42 views
Skip to first unread message

Yash Lanjewar

unread,
Sep 10, 2020, 10:02:09 AM9/10/20
to django...@googlegroups.com
1.png
2.png
3.png
4.png

Mohammad Ahshan Danish

unread,
Sep 10, 2020, 10:08:18 AM9/10/20
to django...@googlegroups.com
url for post_detail should have <pk>

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAM%3DybSOsbGWm-9LvGYgu5QpNQZA%3DZvGY00C%2Bj5CHuoiG8nmFxQ%40mail.gmail.com.


--
Thanks & Regards 
  
Regards, 
Danish

amr

unread,
Sep 10, 2020, 1:15:12 PM9/10/20
to Django users
In your views function you passed a (pk) so you must pass it in your path in (urls.py) as
path('postdetail/<int:pk>/', views.post_detail, name='post_detail') 
Then in your template in(href="{% url 'appname:post_detail' post.id %}") 
and you will redirect to your  url as (localhost:port/postdetail/1) or 2 or 3 or 4 ..... or whatever
hope this helps    

Hedrick Godson's

unread,
Sep 11, 2020, 6:10:38 AM9/11/20
to django...@googlegroups.com
In ur anchor tag in template {% url "xyz:rst" post.pk %} 

Reply all
Reply to author
Forward
0 new messages