Hi all i'm trying to use model_form from wtforms on my app engine
model. The model looks like this
class Test(db.Model):
name = db.StringProperty(required=True)
adress = db.StringProperty(required=True)
and i'm initializing the model_form like this.
---
handelsers.py
from wtforms.ext.appengine.db import model_form
from tipfy.ext.jinja2 import render_response
form = model_form(Restaurant,only=['name'])
context = {
"form":form
}
return render_response('index2.html',**context)
---
and the jinja-template like this
---
{% from '_jinja_form_macros.html' import form_field %} <-- Using the
jinja macro's from tipfy's homepage
<form id="create-form" method="post" action="/create_restaurant">
{{ form_field(
form.name, class='medium') }}
{{ form_field(form.adress, class='medium') }}
<input id="submit" type="submit" name="submit" disabled="true" /
>
</form>
i've tried everything i could possibly think of, and my thought right
now is pointing to the jinja macro'sm the error can be seen below..
Sadly google tell's me that no one have ever encountered this problem,
so please help ! I've tried logging the field
form.name through
pythons logging and it tells me
---
INFO 2011-01-03 20:08:46,625 handlers.py:24]
<UnboundField(TextField, (), {'
default': None, 'validators': [<wtforms.wtforms.validators.Required
object at 0x
0889BD70>, <wtforms.wtforms.validators.Length object at 0x0888E1D0>],
'label': '
Name'})>
---
So there is definitely a field called label ! :/ Error below
Traceback (most recent call last):
File "C:\Users\jakobsuper\Documents\tipfy\anymenu\distlib\tipfy
\__init__.py", line 442, in wsgi_app
response = self.handle_exception(request, e)
File "C:\Users\jakobsuper\Documents\tipfy\anymenu\distlib\tipfy
\__init__.py", line 430, in wsgi_app
rv = self.dispatch(request)
File "C:\Users\jakobsuper\Documents\tipfy\anymenu\distlib\tipfy
\__init__.py", line 559, in dispatch
return handler(self, request)(method, **request.rule_args)
File "C:\Users\jakobsuper\Documents\tipfy\anymenu\distlib\tipfy
\__init__.py", line 152, in __call__
return method(*args, **kwargs)
File "C:\Users\jakobsuper\Documents\tipfy\anymenu\apps\restaurants
\handlers.py", line 30, in get
return render_response('index2.html',**context)
File "C:\Users\jakobsuper\Documents\tipfy\anymenu\distlib\tipfy\ext
\jinja2\__init__.py", line 172, in render_response
return Tipfy.app.response_class(render_template(filename,
**context),
File "C:\Users\jakobsuper\Documents\tipfy\anymenu\distlib\tipfy\ext
\jinja2\__init__.py", line 159, in render_template
return jinja2.get_template(filename).render(**context)
File "C:\Users\jakobsuper\Documents\tipfy\anymenu\distlib
\jinja2\environment.py", line 891, in render
return self.environment.handle_exception(exc_info, True)
File "C:\Users\jakobsuper\Documents\tipfy\anymenu\templates
\index2.html", line 85, in top-level template code
{{ form_field(
form.name, class='medium') }}
UndefinedError: 'wtforms.fields.UnboundField object' has no attribute
'label'