1👍
✅
The origin_station
and destionation_station
likely each point to a single station, so then you use a ForeignKey
[Django-doc], not a ManyToManyField
:
class BusStation(models.Model):
bus_station = models.CharField(max_length=80)
bus_station_identifier = models.IntegerField()
def __str__(self):
return self.bus_station
class Route(models.Model):
origin_station = models.ForeignKey(
BusStation, related_name='starting_routes'
)
destination_station = models.ForeignKey(
BusStation, related_name='ending_routes'
)
data = models.JSONField()
slug = models.SlugField(unique=True, null=True)
def __str__(self):
return f'{self.origin_station} - {self.destionation_station}'
Source:stackexchange.com