django related_name in the role and usage

In fact, it can be understood as the solution to many relationship to take an object
can be referenced from understanding the relationship between the main
references from the master, that many, pay attention to foreign key field is placed at one end and more, such as a class class many students students, then the set class type is a foreign key field value students in the class which
take students from class to get good data, studets.class to get
it to take data from the class students took bad, of course, you can take the default way class.students_set.all () can get
but this is trouble, it simply is to set a related_name = classs properties directly class.classs.all () on it

Guess you like

Origin www.cnblogs.com/zhoajiahao/p/11390027.html