hello,
-- i want to create a query for likes in my post details
my html tags
<p>{{movies.likes}} peaple liked this article</p>
<p><a href="/like/{{post.id}}">Like</a></p>
my urls
url(r'^view/(?P<slug>[^\.]+)/$', views.view_post, name='view_post'),
url(r'^(?P<pk>[0−9]+)/$', views.like_post, name='like_post'),
my view
def like_post(request,pk=1):
a=Movies.objects.get(pk=pk)
count=a.likes
count+=1
a.likes=count
a.save()
return HttpResponseRedirect ( '/posts/view/%s' % pk)but i have error not workPage not found (404)
Request Method: GET Request URL: http://127.0.0.1:8000/like/1/ Using the URLconf defined in
categories1.urls, Django tried these URL patterns, in this order:
- ^admin/
- ^$ [name='index']
- ^view/(?P<slug>[^\.]+)/$[name='view_post']
- ^category/(?P<slug>[\w-]+)/$[name='view_category']
- ^(?P<pk>[0−9]+)/$ [name='like_post']
- ^media\/(?P<path>.*)$
The current URL,
like/1/, didn't match any of these.any idea ?
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bd58b974-1c93-498b-a9b3-30503e209e51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment