开发者

How to filter data from model?

开发者 https://www.devze.com 2023-04-09 19:39 出处:网络
I have two models: class ModelOne(models.Model): something = models.TextField[...] class ModelTwo(models.Model):

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().

0

精彩评论

暂无评论...
验证码 换一张
取 消