title: How to use Django forms ModelChoiceField with external database values
body: <p>I am trying to use a ModelChoiceField to get the values populated from an external database.</p>
  
  <p>I have added an additional database in my setting.py and have set up a externaldb.py file in my app as follows:</p>
  
  <pre><code>from django.db import connections
  
  def Location():
  
      rs = []
  
      cursor = connections['mydb'].cursor()
      cursor.execute("SELECT city FROM db.data_center WHERE removed is null;")
      zones = cursor.fetchall()
  
          for v in zones[::]:
              rs.append(v)
  </code></pre>
  
  <p>The using python manage.py shell I can do this</p>
  
  <pre><code>&gt;&gt;&gt;from platform.externaldb import Location
  &gt;&gt;&gt;print Location()
  &gt;&gt;&gt;[(u'India-01',), (u'Singapore-01',), (u'Europe-01',)]
  </code></pre>
  
  <p>So I am getting values but how to I get that to appear in a drop down box.. This is my forms.py</p>
  
  <p>forms.py</p>
  
  <pre><code>from platform.externaldb import Location
  
  zone = forms.ModelChoiceField(Location(), label='Zone')
  </code></pre>
  
  <p>But this doesn't work for me.. How do I do this so the 3 values appears in the ModelChoiceField drop down list?</p>
  
  <p>Thanks - Oli</p>