Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过url将变量从html模板传递到django中的view方法_Django_Django Templates - Fatal编程技术网

如何通过url将变量从html模板传递到django中的view方法

如何通过url将变量从html模板传递到django中的view方法,django,django-templates,Django,Django Templates,我想将一个变量从html模板传递到django中的视图方法,以便在python视图方法中使用它 下面是我的html代码: <li><a href="{%url 'Automation:rollbackAAI' router_hostname %}">Rollback</a> 但是,在加载html模板时,会出现以下错误: Reverse for 'rollbackAAI' with arguments '('a2router',)' and keyword a

我想将一个变量从html模板传递到django中的视图方法,以便在python视图方法中使用它

下面是我的html代码:

<li><a href="{%url 'Automation:rollbackAAI' router_hostname %}">Rollback</a>
但是,在加载html模板时,会出现以下错误:

Reverse for 'rollbackAAI' with arguments '('a2router',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['vpesat/rollbackAAI/(?P<router_name>[a-z]+)$']
未找到参数为“('a2router',)”和关键字参数为“{}”的“rollbackAAI”的反向。尝试了1个模式:['vpesat/rollbackAAI/(?P[a-z]+)$']
路由器名称中有一个与正则表达式不匹配的数字。您可能应该使用与所有字母数字字符匹配的
\w

r'rollbackAAI/(?P<router_name>\w+)$'
r'rollbackAAI/(?P\w+)$'
Reverse for 'rollbackAAI' with arguments '('a2router',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['vpesat/rollbackAAI/(?P<router_name>[a-z]+)$']
r'rollbackAAI/(?P<router_name>\w+)$'