Skip to content

back_populates on relationship x refers to attribute y that is not a relationship #932

Discussion options

You must be logged in to vote

Hey, back_populates refers to the name of the relationship in the related class.

So in your case you should have something like that:

class Cids(rx.Model, table=True):
    cid: str = Field(primary_key=True)
    company: str

    tickets: list["Servers"] = Relationship(back_populates="company")  

class Servers(rx.Model, table=True):
    cid: str = Field(foreign_key="cids.cid")
    ticket_number: str
    instance: int
    owner: str
    template: str
    power_state: int = 0
    note: str | None = None

    company: Cids = Relationship(back_populates="tickets")

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by greenseeker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants