Since there are many stops along the route, and stops can belong to several routes, I would use ManyToMany to maintain this relationship. You can specify a through model to store relationship data, for example, at what time the route is expected to reach this stop. There are many options for adding order information. One naive way would be to have an Integer order field, as shown below, or you could preserve the non-existence of order through arrival_time. If these routes do not change frequently, IntegerField is not a terrible implementation. However, if they change frequently, you need to update the fields ... not perfect.
class Stop(models.Model): name = .. latitude = .. longitude = .. class Route(models.Model): stops_list = models.ManytoManyField(Stop, through='StopInfo')
source share