Skip to content
Advertisement

NoReverseMatch Reverse for ‘save-post’ with arguments ‘(”,)’ not found. 1 pattern(s) tried: [‘save/(?P[0-9]+)$’]

I cannot figure out why I keep getting this “NoReverseMatch at /“. I am trying to add AJAX to a form to save posts. It seems to be a problem with the URL in the Javascript, but I cannot figure out exactly what it is. Can anyone tell me what is wrong here? Thank you in advance.

urls.py

JavaScript

views.py

JavaScript

popular.html

JavaScript

Javascript

JavaScript

Fixed the views.py

Advertisement

Answer

Error is comming from this line url: "{% url 'save-post' post.id %}", here you don’t have access to your post object because it’s not inside loop you can solve your problem like this you don’t have create form and set your button type to submit if you’re using ajax request change your code like this

JavaScript

and you ajax call will look like this

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement