DEV Community

MahfuzKhandaker
MahfuzKhandaker

Posted on

Django Jquery Ajax Like Section is not working

I am trying to create dynamic like functionality in Django. But it shows following error:

Not Found: /blogs/why-do-we-use-it/{% url "like_post" %}

Here is my urls.py:

urlpatterns = [
   path('', PostListView.as_view(), name='post-list')
   path('like/', like_post, name='like_post'),
   path('<slug:slug>/', post_detail, name='post-detail'),
]

models.py:

likes = models.ManyToManyField(get_user_model(), blank=True, related_name='likes')

views.py:

def like_post(request):
    post = get_object_or_404(Post,

Top comments (0)