title: How to make WTForms read from the datastore?
body: <p>I'm trying to enable a use case "add city" where I got model definitions for region and city where a city belongs to a region:</p>
  
  <pre><code>class Region(db.Model):
    name = db.StringProperty()
    vieworder = db.IntegerProperty()
    image = db.BlobProperty()
  
  class City(db.Model):
    region = db.ReferenceProperty()
    name = db.StringProperty()
    image = db.BlobProperty()
    vieworder = db.IntegerProperty()
    areacode = db.IntegerProperty()
  </code></pre>
  
  <p>I then add regions manually and have made a form to add the cities:</p>
  
  <pre><code>class AddCityForm(Form):
  
      my_choices = [
          ('0', _('All regions')),
          ('1', _('Delhi')),
      ]
      region = SelectField(choices=my_choices)
      name = TextField(_('Name'))
  
  class AddCityHandler(BaseRequestHandler):
  
      def get(self):
          logging.info('i baserequesthandler')
          self.render('addcity.html', {'form': AddCityForm()})
  </code></pre>
  
  <p>Now I want the choices to read from the data layer and be all the regions like <code>Region.all()</code> and the IDs the IDs of the entities so that I can populate a city with the key of the region as a reference which region it belongs to. Can you tell me how I can make WTForms populate the options from the datastore with my regions?</p>
  
  <p>THank you</p>
  
  <h2>Update</h2>
  
  <p>In GAE, the following code works to make option read from datastore</p>
  
  <pre><code>class RegionField(SelectField):
  
      def __init__(self, *args, **kwargs):
          super(RegionField, self).__init__(*args, **kwargs)
          self.choices = []
          for region in Region.all().fetch(99999):
          self.choices.append([region.key().id(), region.name])
  
  class AddCityForm(Form):
      region = RegionField()
      name = TextField(_('Name'))
  </code></pre>