Alright, so I'm sure the title was rather confusing so I'll do my best to explain here. I'm in the process of creating a simple website that allows people to search for movies and TV shows. If they're a user they also have the ability to add Movie/Tv show to their watchlist. As of right now, I have these tables:
class User(db.Model, UserMixin):
id = db.Column(db.Integer, autoincrement=True, primary_key=True)
watchList_id = db.Column(db.Integer, db.ForeignKey('watchList.watchList_id'), nullable=False, autoincrement=True)
first_name = db.Column(db.String(120))
last_name = db.Column(db.String(120))
email = db.Column(db.String(180), unique=True)
password = db.Column(db.String(255))
is_admin = db.Column(db.Boolean(), default=False)
active = db.Column(db.Boolean())
confirmed_at = db.Column(db.DateTime())
roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))
class watchList(db.Model):
__tablename__ = "watchList"
watchList_id = db.Column(db.Integer, autoincrement=True, primary_key=True)
title = db.Column(db.String(200), unique=True)
releaseDate = db.Column(db.Date)
producer = db.Column(db.String(100))
description = db.Column(db.String(300))
genre = db.Column(db.String(50))
image = db.Column(db.String(300))
I basically want the functionality to where when a user gets created a watchlist for that user also gets created, but right now I keep getting the error that theirs no value for watchList_id when a user gets created which makes sense since I have to idea how to do that. I was thinking of somehow setting the user_id == watchList_id, but I wasn't sure how to do that. Any ideas? I can send more code if needed. I'm using flask-security so I don't know how to see the python/flask code for Register.