pyramid - SQLAlchemy / WTForms QuerySelectField -
i attempting use wtforms sqlalchemy extension on pyramid application.
i have done:
from wtforms import form, textfield,textareafield, validators wtforms.ext.sqlalchemy.fields import queryselectfield app.models import dbsession app.models import parentmodel class newchild(form): title = textfield('title:', [validators.required()]) intro = textareafield('introduction:') body = textareafield('body:') parent = queryselectfield(query_factory=dbsession().query(parentmodel).all)
dbsession defined as
dbsession = scoped_session(sessionmaker(extension=zopetransactionextension()))
the query seems work, display in template reading
<app.models.parentmodel object @ 0x9xxx>
or such. doing wrong?
you need define a __str__
method on parentmodel
Comments
Post a Comment