title: WTForms not working on Google App Engine 1.6.1 & Python 2.7
body: <p>I'm new at GAE and all that python stuff, so question might be stupid at last.)</p>
  
  <p>I have model:</p>
  
  <pre><code>from google.appengine.ext import db
  
  class Task(db.Model):
      name = db.StringProperty()
      summary = db.StringProperty(multiline=True)
  </code></pre>
  
  <p>and I want to auto generate form, so: </p>
  
  <pre><code>import webapp2
  import jinja2
  import os
  
  from wtforms.ext.appengine.db import model_form
  
  from Tasks.model import Task
  
  jinja_environment = jinja2.Environment(
      loader=jinja2.FileSystemLoader(os.path.dirname(__file__) + '/../templates/admin'))
  
  class AddTaskPage(webapp2.RequestHandler):
      def get(self):
  
          AddForm = model_form(Task)
          template_values = {
              'form_self_link': self.request.path,
              'form_content': AddForm
          }
  
          template = jinja_environment.get_template('add_task.html')
          self.response.out.write(template.render(template_values))
  </code></pre>
  
  <p>add_task.html template:</p>
  
  <pre><code>&lt;form method="POST" action="{{form_self_link}}"&gt;
      {{form_content}}
      &lt;input type="submit" value="Add"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And the most confusing is output – </p>
  
  <pre><code>&lt;form method="POST" action="/admin/tasks/add"&gt;
      &lt;class 'wtforms.ext.appengine.db.TaskForm'&gt;
      &lt;input type="submit" value="Добавить"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>There is NO form's elements, there is just very strange <code>&lt;class 'wtforms.ext.appengine.db.TaskForm'&gt;</code> stuff.</p>
  
  <p>I use GAE 1.6.1, python 2.7.2, jinja 2.6 (bundled with GAE), WTForms 0.6.3 (latest) </p>
  
  <p>Could you please help?</p>
  
  <p>UPDATE:
  I've used instruction bundled with class and it is not working:</p>
  
  <pre><code>   from google.appengine.ext import db
     from tipfy.ext.model.form import model_form
  
     # Define an example model and add a record.
     class Contact(db.Model):
         name = db.StringProperty(required=True)
         city = db.StringProperty()
         age = db.IntegerProperty(required=True)
         is_admin = db.BooleanProperty(default=False)
  
     new_entity = Contact(key_name='test', name='Test Name', age=17)
     new_entity.put()
  
     # Generate a form based on the model.
     ContactForm = model_form(Contact)
  
     # Get a form populated with entity data.
     entity = Contact.get_by_key_name('test')
     form = ContactForm(obj=entity)
  </code></pre>
  
  <p>The only strange moment is "from tipfy.ext.model.form import model_form" string, but I think it is just an error in docs.</p>
  
  <p>UPDATE 2</p>
  
  <p>Well I managed to get it work and may be I missed something, seems like there is no feature "auto print form" in WTForm. So it works now like that:</p>
  
  <pre><code>class AddTaskPage(webapp2.RequestHandler):
      def get(self):
          AddForm = model_form(Task)()
          template_values = {
              'form_self_link': self.request.path,
              'form_name_field': AddForm.name
          }
  
          template = jinja_environment.get_template('add_task.html')
          self.response.out.write(template.render(template_values))
  </code></pre>
  
  <p>And prints out </p>
  
  <pre><code>&lt;form method="POST" action="/admin/tasks/add"&gt;
      &lt;input id="name" name="name" type="text" value=""&gt;
      &lt;input type="submit" value="Добавить"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Well... seems like the only option is to do something like in future (taken from docs)</p>
  
  <pre><code>&lt;form method="POST" action="/..."&gt;
      &lt;div&gt;{{ form.username.label }}: {{ form.username(class="css_class") }}&lt;/div&gt;
      &lt;div&gt;{{ form.password.label }}: {{ form.password() }}&lt;/div&gt;
  &lt;!-- and so on .... --&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Is it really no any auto-generate and auto-print form libraries for GAE with Python 2.7?(</strong></p>
  
  <h2>LAST UPDATE</h2>
  
  <p>Well... I found one option to get it work and render all form elements:</p>
  
  <pre><code>class AddTaskPage(webapp2.RequestHandler):
      def get(self):
          addForm = model_form(Task)()
          template_values = {
              'form_self_link': self.request.path,
              'form': addForm
          }
  
          template = jinja_environment.get_template('add_task.html')
          self.response.out.write(template.render(template_values))
  
      def post(self):
          addForm = model_form(Task)(self.request.POST)
          template_values = {
              'form_self_link': self.request.path,
              'form': addForm
          }
  
          template = jinja_environment.get_template('add_task.html')
          self.response.out.write(template.render(template_values))
  </code></pre>
  
  <p>In template:</p>
  
  <pre><code>{% for field in form %}
      &lt;tr&gt;
          &lt;th&gt;{{ field.label }}&lt;/th&gt;
          &lt;td&gt;{{ field }}&lt;/td&gt;
      &lt;/tr&gt;
  {% endfor %}
  </code></pre>
  
  <p>Looks not so bad .)</p>