Pyvmomi get folders name
<p>I'm new to Python and Django and I need to list all my VMs.
I used pyvmomi and Django but I can't get the folders name from VSphere, it shows a strange line.</p>

<blockquote>
  <p>VMware list</p>
  
  <p>'vim.Folder:group-v207'</p>
  
  <p>'vim.Folder:group-v3177'</p>
  
  <p>'vim.Folder:group-v188'</p>
</blockquote>

<p>I have 3 folders on vSphere so I think my connection it's good but that's absolutely not their names.</p>

<p>Here is my code :</p>

<p>views.py</p>

<pre><code>from __future__ import print_function
from django.shortcuts import render
from pyVim.connect import SmartConnect, Disconnect
import ssl

def home(request):
    s = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
    s.verify_mode = ssl.CERT_NONE
    try:
        connect = SmartConnect(...)
    except:
        connect = SmartConnect(...)
    datacenter = connect.content.rootFolder.childEntity[0]
    vmsFolders = datacenter.vmFolder.childEntity
    Disconnect(connect)
    return render(request, 'vmware/home.html', {'vmsFolders':vmsFolders})
</code></pre>

<p>home.html</p>

<pre><code>&lt;h1&gt;VMware list&lt;/h1&gt;
{% for vmFolder in vmsFolders %}
&lt;div&gt;
    &lt;h3&gt;{{ vmFolder }}&lt;/h3&gt;
&lt;/div&gt;
{% endfor %}
</code></pre>

<p>Can anybody help me to get the real names of my folders?</p>

<p>You need to specifically state you want the name, like this:</p>

<pre><code>vmFolders = datacenter.vmFolder.childEntity
for folder in vmFolders:
    print(folder.name)
</code></pre>

python django vsphere pyvmomi