1

I found this on DatePickerWidget with Flask, Flask-Admin and WTforms and this is perfect but I need two datepickers because I want to pickup 2 date (start and end date) for SQL query

py file:

class ExampleForm(Form):
    dt = DateField('DatePicker', format='%Y-%m-%d')

and here I assign to variable:

date = form.dt.data.strftime('%Y-%m-%d')

html file:

<form action="#" method="post">
    {{ form.dt(class='datepickerA') }}
    {{ form.hidden_tag() }}
    <input type="submit"/>

I'm not sure how to add one more picker and assign to 2 variable in py file?

Thanks in advance

radojicic
  • 27
  • 5
  • I tried to install **flask.ext.admin.form** but pip did not find it. Any help will be appreciated. – Zvi Sep 11 '22 at 15:31

1 Answers1

4

Your ExampleForm class needs to have two members:

class ExampleForm(Form):
    dStart = DateField(...)
    dEnd = DateField(...)

Then in your form, you would use something like this:

<form action="/process" method="POST">
    {{ form.dStart.label }} {{ form.dStart() }}
    {{ form.dEnd.label }} {{ form.dEnd() }}
    <input type="submit">Do it!</input>
</form>
James McPherson
  • 2,476
  • 1
  • 12
  • 16