Pass request object and query to templates.