示例:
class Route(models.Model):
last_waypoint_visited = models.ForeignKey('WayPoint')
class WayPoint(models.Model):
route = models.ForeignKey(Route)
由于WayPoint已经通过路线字段引用了Route,因此我并不需要使用last_waypoint_visited字段来生成Route的后向引用。
是否可以禁用" last_waypoint_visited"场?
答案 0 :(得分:16)
是的,这是documented feature:
last_waypoint_visited = models.ForeignKey('WayPoint', related_name='+')