I'm trying to make a few inputs have a default value retrieved from MongoDB, using mongoengine.
But when I'm trying to set a default value like this...
# Edit form (wtform)
class EditForm(FlaskForm):
firstname = StringField('First name', default = current_user.firstname)
...
... I get an error:
AttributeError: 'NoneType' object has no attribute 'firstname'
How do I solve this issue?
Can I somehow pass "current_user.firstname" by value in .html file?:
{{ form.firstname(class_='form-control', placeholder_='First name', value_='current_user.firstname') }}
{{ form.firstname.label(for_='firstname') }}
I found the solution by myself. For future reference, all I had to do was to remove '' from value_:
{{ form.firstname(class_='form-control', placeholder_='First name', value_=current_user.firstname) }}
{{ form.firstname.label(for_='firstname') }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.