2 models need to relate to each other via different fields #960
-
Here you can see that the Basket can have multiple Items related to it, and it also has an ID of the first item that has been put there. I couldn't find how to relate them to each other in documentation, Q&A section, and via google search. I hope someone can help me out.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In my opinion, this problem have two diferents ways to by resolved.
`class Basket(ormar.Model): class Item(ormar.Model):
class Item(ormar.Model): I hope it helps you! |
Beta Was this translation helpful? Give feedback.
In my opinion, this problem have two diferents ways to by resolved.
`class Basket(ormar.Model):
id: int = ormar.Integer(primary_key=True)
initial_item: Item = ormar.ForeignKey(Item, related_name="for_basket", nullable=True)
class Item(ormar.Model):
id: int = ormar.In…