Hello friends, I am building a website with Django, I decided to create a filter for my items, you can filter items like this: Item.objects.filter(type=item_type)
, so basically I created an url which takes a slug:item_type, and returns a JsonResponse with the items parsed as JSON.
Then I created an Ajax call in my js file and when I wanted to call the url to filter by type I keep getting an error:
function filterItemType(type) {
$.ajax({
type: "GET",
data: $(this).serialize(),
url: "{% url 'boring:filter_items' type%}",
...
The Error:
Not Found: /boring/{% url 'boring:filter_items' type%}
[21/Jun/2021 11:32:54] "GET /boring/%7B%%20url%20'boring:filter_items'%20type%%7D HTTP/1.1" 404 6103
So basically, for my understanding, JS is not parsing the Django {% url .... %}. I have no idea how to do it in order for JS to build the route...like I usually do it in the Templates...
PS: I also tried to build the route with the type separated as -> url: "{% url 'boring:filter_items' %}" + "/"+ type;
But it's not working either, same error.