Here are the two classes I've defined.
class Day(db.Model):
__tablename__ = 'day'
__table_args__ = {'extend_existing': True}
id = db.Column(db.Integer, nullable = False, primary_key = True)
name = db.Column(db.String(9), nullable = False)
#Foreign Keys
function_id = db.Column(db.Integer, db.ForeignKey(Function.id))
schedule_id = db.Column(db.Integer, db.ForeignKey(Schedule.id)) #Python wont recognize this for some reason...
class Schedule(db.Model):
__tablename__ = 'schedule'
__table_args__ = {'extend_existing': True}
id = db.Column(db.Integer, nullable = False, primary_key = True)
#Foreign Keys
assigned_employee = db.Column(db.Integer, db.ForeignKey(Employee.id))
#Relationships
days = db.relationship('Schedule', backref = 'day', lazy = True)
I'm using python in the command prompt to check the code and it seems to not recognize the Schedule class right below it.
Traceback (most recent call last):
File "models.py", line 1, in from main import db
File "Not\The\Actual\Path.py", line 9, in from views import *
File "Not\The\Actual\Path.py", line 2, in from models import *
File "Not\The\Actual\Path.py", line 48, in class Day(db.Model):
File "Not\The\Actual\Path.py", line 57, in Day schedule_id = db.Column(db.Integer, db.ForeignKey(Schedule.id)) #Python wont recognize this for some reason...
NameError: name 'Schedule' is not defined
It's perfectly fine with the 'function_id' line, but angry about the one right below it.