Composite Foreign Key FieldΒΆ

viewflow.fields.CompositeKey - Virtual field allows Django to get access to database tables with ForeignKey. The field does not provide support for migrations, and suitable only for Meta.managed = False models only

from viewflow.fields import CompositeKey

class Seat(models.Model):
    id = CompositeKey(columns=['aircraft_code', 'seat_no'])
    aircraft_code = models.ForeignKey(Aircraft, models.DO_NOTHING)
    seat_no = models.CharField(max_length=4)

class Meta:
    managed = False
    db_table = 'aircrafts_data'