I have two models:
class ModelOne(models.Model):
something = models.TextField[...]
class ModelTwo(models.Model):
other_something = models.TextField[...]
ref = models.ForeignKey(ModelOne)
And I want to write function in ModelOne which return me all related objects from M开发者_开发问答odelTwo.
It's important: In ModelOne.
How to do it?
Invoke self.modeltwo_set.all()
.
精彩评论