Tuesday, September 22, 2015

Re: Reverse for 'post_detail' with arguments '()' and keyword arguments '{'pk': 1}' not found. 1 pattern(s) tried:

According to the error, your pattern starts with $, which is an obvious mistake.

But the "url.py" you quote has ^.

Maybe it was using an old version, or you haven't copied the right one.

Greetings,
Remco Gerlich


On Sat, Sep 19, 2015 at 9:42 AM, sankar vasu <sankarmcp13@gmail.com> wrote:
Hi All,

I got below error, please advise. please look at the following link: http://pysan.pythonanywhere.com/




url.py

from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$', views.post_list, name='post_list'),
    url(r'^post/(?P<pk>[0-9]+)/$', views.post_detail, name='post_detail'),
]


view.py

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

def post_list(request):
    posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
    return render(request, 'blog/post_list.html', {'posts': posts})

def post_detail(request, pk):
    post = get_object_or_404(Post, pk=pk)
    return render(request, 'blog/post_detail.html', {'post': post})


Thanks in advance,
Sankar B

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPzi0vCzoaSN%2B6xEL%3D%2BPSu_vQMpqG6i8oFw9y4_mtPvO8xtoeg%40mail.gmail.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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFAGLK1hvR4aU%3DsJ-YFrxivs6QxdpZk1LsgDZKN5JbZ3h6sOnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment