Inappropriate Datetime Datatype And Error On Flask App
Background What I would like to do is to implement a form to insert datetime with the specific data type (like 2019-10-23 22:38:18) on a web application written in Python Flask and
Solution 1:
First, you are using your form
in quite and unconventional way. Not that its wrong, its just that it's different from the typical which makes googling
for help more difficult.
Now on to your question...
The reason you are getting this error is because you haven't passed a form
variable for your template to use. Your index route would look something like:
@app.route('/')defindex():
return render_template('index.html', data=Todo.query.all(), form=form)
However the above won't work because you haven't defined a form in your index()
route. So you have to implement your datetime
atttribute the same way you did for name
and city
inside your jinja template. Instead of:
Baca Juga
- Populate The Drop-down Menu Based On Previous Selection In Flask Python Without Using Ajax?
- Couldn't Apply Javascript To My Template In Flask Despite Having It In The Static Dir. How Do I Resolve That In The Code Below?
- Jinja2.exceptions.templatesyntaxerror: Expected Token 'end Of Print Statement', Got 'posted'
{{ form.datetime(class_ = 'form-control', placeholder='YYYY-MM-DD HH:MM', autofocus = true) }}
you will need to create the html yourself. For example:
<inputid="datetime"type="datetime-local">
you can look through the docs to see all the options you have for specifying a datetime-local
input type.
Post a Comment for "Inappropriate Datetime Datatype And Error On Flask App"