title: Setting DateTime in Flask App
body: <p>I am working on a flask app and I was wondering if someone can help me figure out why I am getting an error as I am trying to set the DateTime when a new user is registering an account. I just want it to save the exact time that the user was registered. The following is the route that I created to add and commit the user to the database. </p>
  
  <pre><code>from flask import Flask, render_template, request, redirect, url_for, flash
  from flask import escape, session
  from datetime import datetime
  from sqlalchemy import create_engine
  from sqlalchemy.orm import sessionmaker
  from database import Users, Base
  
  app.route('/registered', methods=['Get', 'POST'])
  def Register():
      if request.method == 'POST':
          password = request.form['password']
          verify = request.form['verify']
          if password == verify:
              newUser = Users(Username = request.form['username'],
                              Password = request.form['password'],
                              Email = request.form['email'],
                              DateTime = datetime.now())
              session.add(newUser)
              session.commit()
              return redirect('HomePage')
          else:
              flash('Passwords do not match')
              return render_template('Register.html')
  </code></pre>
  
  <p>And here is the database structure that I currently have setup:</p>
  
  <pre><code>class Users(Base):
      __tablename__ = 'users'
  
      Id = Column(Integer, primary_key = True)
      Username = Column(String(22), unique = True, nullable = False)
      Password = Column(String(22), nullable = False)
      Email = Column(String(55), unique = True, nullable = False)
      Registered = Column(DateTime, nullable = False)
  </code></pre>
  
  <p>I am not sure if the html file would have anything with setting up the datetime property.</p>
  
  <p>If anyone can help. it would be much appreciated.</p>