0
這裏是我的model.py是什麼樣子:如何在同一個模型中存儲同一對象的多個實例?
class Person(models.Model):
person_name = models.CharField(max_length=50)
owned_items = models.ForeignField("Item")
class Item(models.Model):
item_name = models.CharField(max_length=50)
item_description = models.TextField()
這是我要存儲
item1 = Item(item_name="keyboard", item_description="computer keyboard)
item2 = Item(item_name="monitor", item_description="used to visualize data")
數據我person
同時擁有item1
和item2
,但我不知道如何以存儲它們:
person = Person(person_name="John Smith", owned_items= ???????)