'Exception Type: NoReverseMatch - Cannot spot problem in code

Good afternoon all,

I am getting the following error message: "Reverse for 'save-review' with arguments '('',)' not found. 1 pattern(s) tried: ['save\-review/(?P[0-9]+)\Z']"

But I cannot spot where the problem is coming from.

URLS

from django.urls import path
from . import views

URL
    urlpatterns = [
    ...
    path('save-review/<int:pid>', views.save_review, name="save-review"),
    ]

VIEWS

def product(request):
    product_list = Product.objects.all()
#set up pagination
    p = Paginator(Product.objects.all(), 20)
    page = request.GET.get('page')
    products = p.get_page(page)
    product_list = Product.objects.all().order_by('?')
    reviewForm = ReviewAdd()
    nums = "a"* products.paginator.num_pages
    return render(request,"main/products.html", {"product_list":product_list,"form":reviewForm,"products":products, "nums":nums})

#save review
def save_review(request,product_id):
    return JsonResponse({'bool':True})

PRODUCT Details

<div class="modal fade" id="productReview" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">Add Product Review</h5>
                            <!--Product Review-->
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <form method="post" id="addForm" action="{% url 'save-review' data.id %}">
                                {% csrf_token%}
                                <table class="table table-bordered">
                                    {{reviewForm.as_table}}
                                    <td colspan="2">
                                        <button type="submit" class="btn btn-primary">Submit</button>
                                        <input type="reset" value="reset" id="reset"></input>
                                    </td>
                                    <tr>
                                    </tr>
                                </table>
                                <p class="ajexRes"></p>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {% endif %}

Any ideas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source