I'm trying to create tables with foreign keys in database with peewee.
Player table has ForeignKey to Team table and Team table has ForeignKey to Player table. When i run my code i'm getting
NameError: name 'Team' is not defined
Here is my code:
class Player(Model):
nickname = CharField(max_length=30)
steam_id = CharField(max_length=15)
team = ForeignKeyField(Team)
class Meta:
database = db
class Team(Model):
name = CharField(max_length=30)
captain = ForeignKeyField(Player)
class Meta:
database = db
Player.create_table()
Team.create_table()
Can someone help me? :)