In my django-view I use pandas to create a pivot table which is then handed via context to the template. This works just fine. I want the headers of the columns to be links triggering new views. So I wrote a simple jQuery script to do this. But I run into problems as soon as I want to pass a kwarg with the url template tag..
$(document).ready(function(){
$('thead th').each(function(){
$(this).html('<a href="{% url "cat_view" cat="' + $(this).html() +'" %}">'+ $(this).html() +'</a>');
});
});
I get the following error:
Reverse for 'cat_view' with arguments '()' and keyword arguments '{'cat': "' + $(this).html() +'"}' not found. 1 pattern(s) tried: ['category/(?P[\w-]+)/$']
my url entry looks like this:
url(r'category/(?P<cat>[\w-]+)/$', categoryView, name='cat_view'),
Am I making an error with the syntax or is it a general problem with my approach? The error message suggests, that django interprets what I write in the jQuery script instead of what the jQuery is supposed to pass over to django.. but I don't know how to avoid this..