Skip to content

Error create schema of two tables, each of which has foreign key to another #264

Answered by sinisaos
serg-yalosovetsky asked this question in Q&A
Discussion options

You must be logged in to vote

@serg-yalosovetsky I'm sorry if this doesn't help, but maybe you can try adding the _name and _table to FK ColumnMeta yourself to prevent this error. Something like this

User.room = ForeignKey(references=Room, on_delete=OnDelete.set_null, null=True)
User.room._setup(table_class=Table)
# adding the `_name` and `_table`
User.room._meta._name = "room"
User.room._meta._table = User
User._meta.columns.append(User.room)
User._meta.foreign_key_columns.append(User.room)

Again, sorry if this doesn't help.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@sinisaos
Comment options

Answer selected by serg-yalosovetsky
@serg-yalosovetsky
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants