Skip to content

Instantly share code, notes, and snippets.

@doobeh
Created March 2, 2016 19:40
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save doobeh/3e685ef25fac7d03ded7 to your computer and use it in GitHub Desktop.
Save doobeh/3e685ef25fac7d03ded7 to your computer and use it in GitHub Desktop.
DatePicker JS Example Flask
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DatePicker Example</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
$( ".dtpick" ).datepicker();
});
</script>
</head>
<body>
<form method="post" action="">
{{ form.hidden_tag() }}
{{ form.dt(class="dtpick") }}
<button type="submit">Go</button>
</form>
</body>
</html>
from flask import Flask, render_template
from flask_wtf import Form
from wtforms import DateField
from datetime import date
app = Flask(__name__)
app.secret_key = 'SHH!'
class DateForm(Form):
dt = DateField('Pick a Date', format="%m/%d/%Y")
@app.route('/', methods=['post','get'])
def home():
form = DateForm()
if form.validate_on_submit():
return form.dt.data.strftime('%x')
return render_template('vort.html', form=form)
if __name__ == '__main__':
app.run(debug=True)
@CharlyJazz
Copy link

thank!

@pkgandhi
Copy link

Is this something doable/embed on bokeh server?

@rizwans-cuelogic
Copy link

how to do year/month/date

@rizwans-cuelogic
Copy link

rizwans-cuelogic commented Dec 5, 2017

@doobeh how to do year/month/date

@a232319779
Copy link

nice!

@catilina17
Copy link

Nice thxxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment