I am trying to create a model to represent travel time between two venues, so it has two foreign keys to the Venue
model:
class VenueTravel(models.Model):
venue1 = models.ForeignKey('Venue', related_name='travel_times')
venue2 = models.ForeignKey('Venue', related_name='travel_times')
minutes = models.IntegerField(default=0, validators=[MinValueValidator(0)])
class Meta:
unique_together = ('venue1', 'venue2')
However, I'm having trouble making the migration for this model because the related name clashes for both fields. Usually, I would understand why, but since in this case the related object relation back to this object represents the same for both fields (all travel distances for the venue, no matter if it's venue1
of venue2
), I don't really care about naming them differently. In fact, I'd want to name them the same.
Is there any way I could do that?
If you think there's a better way of modelling this use case, please feel free to make your suggestion.