title: NOT NULL constraint Failed in Flask + SQLite3
body: <p>I got this error in my app flask</p>
  
  <pre><code>IntegrityError: (sqlite3.IntegrityError) NOT NULL constraint failed:
           auth_user.role [SQL: u'INSERT INTO auth_user (username, email, password, role, status) VALUES (?, ?, ?, ?, ?)']
       [parameters: (u'Natali', u'mail@gmail.com', 'pbkdf2:sha1:1000$p8jlOhqU$fa51e0491a729cef6d05dbd9f1d868455de4be9c', None, None)]
  </code></pre>
  
  <p>However, I think that the code is fine.
  I don't know why doesn't work properly, the values that are as None are allowed to do it, because null=True.</p>
  
  <p>My files are the following</p>
  
  <p>This is my models.py</p>
  
  <pre><code>from app import db
  from werkzeug import generate_password_hash, check_password_hash
  
      class User(db.Model):
  
          __tablename__ = 'auth_user'
  
          id      = db.Column(db.Integer, primary_key=True)
          username = db.Column(db.String(128),  nullable=False)
          email    = db.Column(db.String(128),  nullable=False,
                            unique=True)
          password = db.Column(db.String(192),  nullable=False)
          role     = db.Column(db.SmallInteger, nullable=True)
          status   = db.Column(db.SmallInteger, nullable=True)
  
          def __init__(self, username, email, password):
  
              self.username = username.title()
              self.email    = email.lower()
              self.password = generate_password_hash(password)
  
          def __repr__(self):
              return '&lt;User %r&gt;' % (self.name)
  
          def set_password(self, password):
              self.pwdhash = generate_password_hash(password)
  
          def check_password(self, password):
              return check_password_hash(self.pwdhash, password)
  </code></pre>
  
  <p>And this is my controller.py</p>
  
  <pre><code>from flask import (
      Blueprint,
      request,
      render_template,
      flash,
      g,
      session,
      redirect,
      url_for
  )
  from werkzeug import check_password_hash, generate_password_hash
  
  from app import db
  from app.authentication.forms import LoginForm, SignupForm
  from app.authentication.models import User
  
  mod_auth = Blueprint('auth', __name__, url_prefix='/auth')
  
  @mod_auth.route('/profile')
  def profile():
  
      if 'email' not in session:
          return redirect(url_for('signin'))
  
      user = User.query.filter_by(email = session['email']).first()
  
      if user is None:
          return redirect(url_for('signin'))
      else:
          return render_template('authentication/profile.html')
  
  @mod_auth.route('/signup/', methods=['GET', 'POST'])
  def signup():
  
      form = SignupForm()
  
      if 'email' is session:
          return redirect(url_for('profile'))
  
      if request.method == 'POST':
          if form.validate() == False:
              return render_template("authentication/signup.html", form=form)
          else:
              new_user = User(form.username.data, form.email.data, form.password.data)
              db.session.add(new_user)
              db.session.commit()
  
              session['email'] = new_user.email
              return "Not found"
  
      elif request.method == 'GET':
          return render_template("authentication/signup.html", form=form)
  
  
  @mod_auth.route('/signin/', methods=['GET', 'POST'])
  def signin():
  
      form = LoginForm(request.form)
      if form.validate_on_submit():
          user = User.query.filter_by(email=form.email.data).first()
          if user and check_password_hash(user.password, form.password.data):
              session['user_id'] = user.id
              flash('Welcome %s' % user.name)
              return redirect(url_for('auth.home'))
  
          flash('Wrong email or password', 'error-message')
  
      return render_template("authentication/signin.html", form=form)
  </code></pre>