Hello everyone!! I'm using supertokens_python libr...
# support-questions-legacy
d
Hello everyone!! I'm using supertokens_python library for django. I have a problem when creating a new table that have a foreign_key reference to a Supertokens table (thirdparty_users). It seems like django ORM cannot find any model name thirdparty_users, so it didn't work. Here are photos of my situation. Any ideas? Should I used raw SQL and ORM at the same time to achieve what I want
r
Hey @dwcquocxa we don’t recommend that you tie your tables directly to ours.
d
Hello!! Thanks for the response! But the idea of my project need to have some tables which have relations with users table which is thirdparty_user I assume
r
If you really want that, then you can copy our schema into your django migrations I guess. I’m not sure why django doesn’t recognise the tables.
You could also just have your own user id table and add to that in the post sign up override
Then your other tables reference this one table.
d
Creating an own user id table is a good idea. I'm thinking about make the foreign key in the django migration file with some raw SQL like this. This code is from chatgpt

https://cdn.discordapp.com/attachments/1109928998731001936/1110096552137084988/Screenshot_2023-05-22_at_9.46.51.png

r
If it works, then cool. I do warn you that upgrades to the core might require migration of these queries.
d
What do you mean by upgrades to the core?
Like when I do signup or signin?
r
The Supertokens core.
Upgrades to the supertoeks core service might require database migration which might affect your foreign key constraints as well
d
I'm already sing supertokens core service, so is that a problem?
r
No. It’s not
d
Thank you!!!
11 Views