Django/Python Javascript Internal Search Keywords

I’m having trouble getting piwik to track internal search results with Python/Django. I have the code as.

_paq.push([‘trackSiteSearch’, {{keyword}},{{category}},{{results}}]);

but this code runs with empty values before the variables get loaded on the page. What would be the right way to do this?