📜  _set in django - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:31.575000             🧑  作者: Mango

代码示例1
# Now, given object e of type Entry, you would do e.blog to access 
# the related object Blog - which is a forward relation. 

class Blog(models.Model):
    pass

class Entry(models.Model):
    blog = Blog(..)

# The _set is a reverse lookup class variable django puts in for you.    
# So, given object b - you would do:
entries = b.entry_set.all()