title: Flask date not set at creation but is set at update
body: <p>views.py</p>
  
  <pre><code>@app.route('/new', methods = ['POST', 'GET'])
  @login_required
  def new():
      form = StudentForm()
      if request.method == 'POST':
          if form.validate_on_submit():
              flash('All fields are required.')
              return render_template('form.html', action = 'new', form = form)
          else:
              student = students(
              request.form['first_name'], request.form['last_name'], \
              request.form['date_of_birth'], \
              request.form['date_of_join'], request.form['address']
              db.session.add(student)
              db.session.commit()
              return redirect(url_for('show_all'))
      return render_template('form.html', action = url_for('new'), form = form)
  
  
  @app.route('/edit/&lt;int:id&gt;', methods = ['POST', 'GET'])
  @login_required
  def edit(id):
      item = students.query.get(id)
      form = StudentForm(obj=item)
      if request.method == 'POST':
          if form.validate_on_submit():
              item = students.query.get(id)
              form = StudentForm(obj=item)
              return render_template('form.html', action = url_for('edit',id = id), form = form)
          else:
              form.populate_obj(item)
              db.session.add(item)
              db.session.commit()
              return redirect(url_for('show_all'))
      return render_template('form.html', action = url_for('edit',id = id), form = form)
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>class students(db.Model):
      __tablename__ = "students"
      id = db.Column('id', db.Integer, primary_key = True)
      first_name = db.Column(db.String(25))
      last_name = db.Column(db.String(25))
      date_of_birth = db.Column(db.Date)
      date_of_join = db.Column(db.Date)
      address = db.Column(db.String(200))
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>class StudentForm(Form):
      first_name = TextField("First Name:")
      last_name =  TextField("Last Name:")
      date_of_birth = DateField("Date of Birth:", format='%m/%d/%Y')
      date_of_join = DateField("Date of Joining:", format='%m/%d-%Y')
      address = TextAreaField("Address:")
      submit = SubmitField("Submit")
  </code></pre>
  
  <p>All other fields are added to the database while adding new item, but the date is not stored. I cant find what the problem actually is. The date field is stored during edit if i use form.validate() for form validation. And if i use form.validate_on_submit() the date field is not stored while adding or editing...</p>