title: pre populate a bootstrapped datepicker datefield format in a flask wtf form using jinja2
body: <p>This code works, except that the populated date is format 2000-08-08. and the date picker is looking for 01-01-2000.</p>
  
  <pre><code>&lt;form class="form form-inline" method="post" role="form"&gt;
  {{ form.hidden_tag() }}
  {{ wtf.form_errors(form) }}
  &lt;input data-provide="datepicker" format="mm/dd/yyyy" id="deadline"  type="text" value="{{ form.deadline.data }}" name="deadline"   required&gt;&lt;/input&gt;
  {{ wtf.form_field(form.complete) }}
  {{ wtf.form_field(form.note) }}&lt;br&gt;
  {{ wtf.form_field(form.submit) }} 
  &lt;/form&gt;  
  </code></pre>
  
  <p>how do i change either the prepopulated format, or the format datepicker wants?
  in my model i have</p>
  
  <pre><code>deadline =DateField( 'Deadline (mm/dd/yyyy)',  format='%m/%d/%Y',validators = [Required()])
  </code></pre>
  
  <p>can i change it in the view?</p>
  
  <pre><code>@app.route('/edit/&lt;name&gt;', methods=['GET', 'POST'])
  def edit_task(name):
      ptask=models.Tasks.query.filter_by(task=task).first()
      form = task_form(obj=ptask)
      form.populate_obj(ptask)
      tform=task_form(request.values)
  </code></pre>
  
  <p><strong>update</strong></p>
  
  <p>changing the formatting line as in </p>
  
  <pre><code> &lt;input data-provide="datepicker" data-date-format="mm/dd/yyyy" id="deadline"  type="text" value="{{ form.deadline.data }}" name="deadline" required&gt;&lt;/input&gt;
  </code></pre>
  
  <p>had no effect, and the date still renders Year/mo/da</p>
  
  <p>But, adding this to my view (as suggested below)</p>
  
  <pre><code>ptask=models.Tasks.query.filter_by(task=task).first()
  form = task_form(obj=ptask)
  form.populate_obj(ptask)
  form.deadline.data = ptask.deadline.strftime("%m/%d/%Y")
  </code></pre>
  
  <p>fixed it.
  Thanks</p>