0
我爲如下時間字段定義wtforms:WTForms日期時間字段的時間沒有更新
stime = DateTimeField(label='Start time',validators=[validators.InputRequired()],format = "%d%b%Y %H:%M",default= datetime.now(timezone('UTC')))
etime = DateTimeField(label='End time',validators=[validators.InputRequired()],format = "%d%b%Y %H:%M",default= datetime.now(timezone('UTC')))
在HTML頁面調用下面這個字段:
<form method= POST action="{{ url_for('input_ext') }}">
<table>
{% for field in form %}
<tr>
<td>{{ field.label }}*</td><td>{{ field }}</td>
</tr>
{% endfor %}
</table>
<input id = "generate" name="generate" type=submit value=Next></form>
瓶代碼:
from flask import Flask
from flask import render_template
from flask import request
from model import InputForm
app = Flask(__name__)
@app.route('/',methods = ['GET','POST'])
#select interface and for selected interfaces pullup circuit info
def provideinput():
global devices
devices = ''
form = InputForm(request.form)
return render_template("utctime.html", form=form)
if __name__ == "__main__":
app.run(debug=True,host="10.23.102.116",port=82)
問題是,我得到UTC的時間,並沒有更新到當前UTC值,只要我重新加載page.It保持相同我開始運行Python代碼。 定義DateTimeField有什麼錯誤?
爲如下,仍然沒有運氣:
stime = DateTimeField(label='Start time(EDT)', validators=[validators.InputRequired()], format="%d%b%Y %H:%M",
default=datetime.today)
etime = DateTimeField(label='End time(EDT)', validators=[validators.InputRequired()], format="%d%b%Y %H:%M",
default=datetime.today)
ETIME = DateTimeField字段(標記= '結束時間(EDT)',驗證器= [validators.InputRequired()],格式=「%d%B%Y%H:% M「, 默認值= datetime.today) - >像這樣仍然是相同的沒有改變後重新加載 – ajay