title: sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) NOT NULL constraint failed: profile.user_id
body: <p>I am new to databases and SQLAlchemy. I currently am making a web app where there are users and each user has profiles they can make. From my knowledge this is a one-to-many relationship. The problem is when I try to make a profile I get the Integrity error and I am not sure why. This is the code in my models file </p>
  
  <pre><code>class User(db.Model, UserMixin):
      id = db.Column(db.Integer, primary_key = True, autoincrement = True)
      username = db.Column(db.String(20), unique = True, nullable = False)
      email = db.Column(db.String(120), unique = True, nullable = False)
      password = db.Column(db.String(60), nullable = False)
      profiles = db.relationship('Profile', backref = 'creator', lazy = True)
  
      def __repr(self):
          return f"User('{self.username}', '{self.email}')"
  
  class Profile(db.Model):
      id = db.Column(db.Integer, primary_key = True)
      profileName = db.Column(db.String(), nullable = False)
      firstName = db.Column(db.String(20), nullable = False)
      lastName = db.Column(db.String(30), nullable = False)
      email = db.Column(db.String(), nullable = False)
      phone = db.Column(db.String(), nullable = False)
      address = db.Column(db.String(), nullable = False)
      address1 = db.Column(db.String(), nullable = True)
      city = db.Column(db.String(), nullable = False)
      state = db.Column(db.String(), nullable = False)
      zipCode = db.Column(db.String(), nullable = False)
      country = db.Column(db.String(), nullable = False)
      cc = db.Column(db.String(16), nullable = False)
      expMonth = db.Column(db.String(2), nullable = False)
      expYear = db.Column(db.String(2), nullable = False)
      cvv = db.Column(db.String(4), nullable = False)
      url = db.Column(db.String(), nullable = False)
      user_id = db.Column(db.Integer(), db.ForeignKey('user.id'), nullable = False)
  </code></pre>
  
  <p>this is the code in my routes file</p>
  
  <pre><code>@login_required
  def newProfile():  
      form = CheckoutForm()
      if form.validate_on_submit():
          profile = Profile(profileName = form.profileName.data, firstName = form.firstName.data, lastName = form.lastName.data, 
          email = form.email.data, phone = form.phone.data, address = form.address.data, address1 = form.address1.data, city = form.city.data,
          state = form.state.data, zipCode = form.zipCode.data, country = form.country.data, cc = form.cc.data, expMonth = form.expMonth.data,
          expYear = form.expYear.data, cvv = form.cvv.data, url = form.url.data, creator = current_user)
          db.session.add(profile)
          db.session.commit()
          flash(f"Profile Created!")
          return redirect(url_for('profiles'))
      return render_template('newProfile.html', title="New Profile", form = form)
  </code></pre>
  
  <p>I am assuming it is something with my profiles and user_id variables, but I can't figure out what. I looked at documentation and looked at some of the solutions on stack overflow but still couldnt get it working. Again sorry if this is a n00b question. I am new to making web apps and using databases so there are a lot of things I am still learning and trying to understand!</p>