模板变量问题
<p>新手,刚学的。 想通过django连接到vcenter获取虚拟机的信息,但是在获取磁盘大小的时候,在html里写了代码报错了</p>
{% for each in children %} 17 {# <li><a href="/detail">{{ each.summary.config.name }}</a><a>------</a><a>{{ each.summary.runtime.powerState }}</a></li> #} 18 <li>{{ forloop.counter }}-{{ each.summary.config.name }}</li> 19 <a>UUID:{{ each.summary.config.uuid }}</a><br/> 20 <a>运行状态:{{ each.summary.runtime.powerState }}</a><br/> 21 <a>IP地址:{{ each.summary.guest.ipAddress }}</a><br/> 22 <a>主机名:{{ each.summary.guest.hostName }}</a><br/> 23 <a>内存大小:{{ each.summary.config.memorySizeMB }}</a><br/> 24 <a>CPU个数:{{ each.summary.config.numCpu }}</a><br/> 25 {% for d in each.config.hardware.device %} 26 <strong> {% if isinstance(d, vim.vm.device.VirtualDisk) is True %}</strong> 27 <a>磁盘大小:{{ d.capacityInKB }}</a> 28 {% endif %} 29 {% endfor %} 30<br /> 31 {% endfor %}</p>
<p> <p>报错信息如下 TemplateSyntaxError at /index/ Could not parse the remainder: '(d,' from 'isinstance(d,' Request Method: GET Request URL: http://127.0.0.1:8001/index/ Django Version: 3.0 Exception Type: TemplateSyntaxError Exception Value: <br /> Could not parse the remainder: '(d,' from 'isinstance(d,' Exception Location: D:\vmproject\venv\lib\site-packages\django\template\base.py in init, line 661 Python Executable: D:\vmproject\venv\Scripts\python.exe Python Version: 3.8.0 Python Path: <br /> ['D:\vmproject', 'C:\Users\sonas\AppData\Local\Programs\Python\Python38\python38.zip', 'C:\Users\sonas\AppData\Local\Programs\Python\Python38\DLLs', 'C:\Users\sonas\AppData\Local\Programs\Python\Python38\lib', 'C:\Users\sonas\AppData\Local\Programs\Python\Python38', 'D:\vmproject\venv', 'D:\vmproject\venv\lib\site-packages', 'D:\vmproject\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg', 'D:\vmproject\venv\lib\site-packages\pip-19.0.3-py3.8.egg']</p>
评论 1
提示Could not parse the remainder: '(d,' from 'isinstance(d,' 。。这是什么问题