Closed r00tat closed 8 years ago
Hey, thanks for this. I'm hitting the same issue. Any reason this hasn't been accepted into the main branch yet?
Ok, I actually ran into a slightly different problem. I changed line 165
if self.data.key == obj.key:
to
if self.data == obj.key:
and my code worked.
A better solution is excluding the field in question from the form. So when I make a form, I say
myform = model_form(MyNDBModel,exclude=['fieldthattakeskeyproperty'])
that means you won't hit this issue.
@savraj no that's not a solution, because I want this field in the form. I.e. you got a Book and a Author model. I want to be able to select the Author and not just ignore it.
Ah yes, sorry about that.
Pull request https://github.com/wtforms/wtforms-appengine/pull/8 seems to include both changes mentioned above.
I've recently taken on maintainership of this repo, and have merged in pull request #8, so I'm going to close this issue as fixed.
I'm using model_form to generate a form for a class with a KeyProperty. If the KeyProperty field is empty, render works fine. If there is already a key, it fails.
The yield line is wrong. self.data is already a key object and not the Model itself. To fix this issue, line 152 in wtforms_appengine/fields.py should look like this: