-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LazyTableReference circular import #935
Comments
@Abdelhadi92 You are right. from piccolo.table import Table
from piccolo.columns import BigSerial, ForeignKey, LazyTableReference
class Limit(Table):
id = BigSerial(primary_key=True)
country = ForeignKey(
references=LazyTableReference(
table_class_name="Country",
module_path="src.modules.compliance.tables",
)
) I actually don't understand why we have both arguments because they serve the same purpose (just my opinion, sorry if I'm wrong) and I think from piccolo.columns.column_types import Varchar to the migrations. After that I ran migrations and everything was fine. from piccolo.table import Table
from piccolo.columns import BigSerial, ForeignKey, LazyTableReference
from src.modules.compliance.tables import Country
class Limit(Table):
id = BigSerial(primary_key=True)
country = ForeignKey(references=Country) I think that with this way of defining ForeignKey, there is less possibility of circular import and other errors. Sorry for long comment. |
Hi @sinisaos, thank you for your response. Regarding import the Table class directly I don't think this will fix the issue if you have foreign key from first to the second app and another one from the first to the second
Piccolo Finder not designed in the right way ... Anyhow, |
I'm sorry to hear that. I will be glad if I can help somehow. |
I'm facing circular import when I use LazyTableReference with app_name, please check the attached video below:
screen-recording-2024-02-28-at-11029-pm_zxUcfsGD.mp4
The text was updated successfully, but these errors were encountered: