Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.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
Javascript 如何将if模板django与变量js连接起来_Javascript_Python_Jquery_Django - Fatal编程技术网

Javascript 如何将if模板django与变量js连接起来

Javascript 如何将if模板django与变量js连接起来,javascript,python,jquery,django,Javascript,Python,Jquery,Django,我想知道是否可以连接Django模板,我做了很多尝试,但都没有成功,如下所示: 功能seeDetail(研究员id){ 让convert_int_research_id=parseInt(research_id) $('#detailReacher').empty(); let元素=` 佩斯基萨多民族自治区详情 阿蒂戈斯 {show_list_articles%} {show_list_article%}中的项目为% {%if article.research\u id`+research\

我想知道是否可以连接Django模板,我做了很多尝试,但都没有成功,如下所示:


功能seeDetail(研究员id){
让convert_int_research_id=parseInt(research_id)
$('#detailReacher').empty();
let元素=`

佩斯基萨多民族自治区详情 阿蒂戈斯 {show_list_articles%} {show_list_article%}中的项目为% {%if article.research\u id`+research\u id+`%} {{文章.研究人员} {{文章标题} {%endif%} {%endfor%} {%endfor%} 项目 {show_list_projetos%中show_list_projeto的% {show_list_projeto%}中项目的% {{project.title} {%endfor%} {%endfor%} `; $('#detailReacher')。追加(元素) }
但当我这样做时,会发生以下错误:

django.template.exceptions.TemplateSyntaxError: Could not parse the remainder: '`+' from '`+'
如果有人能帮助我并解释原因,我将不胜感激


是的,我在
控制台.log中看到了它,这实际上是一个字符串类型的值,我试图转换它,但出现了相同的错误。

使用
{%if article.research_id
+research_id+
%}
时,您到底想做什么,但即使是这样,这也无法工作,因为模板是在服务器上评估的,远远早于JS可以在客户端上运行。@scharette在这篇文章中,因为有不常用的研究者id,我想与我在函数中得到的那个进行比较