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
To use CompositeKey, import it from viewflow.fields and define it in your model. The following example demonstrates how to use CompositeKey with a Seat model, which references an Aircraft model via a composite key consisting of aircraft_code and seat_no.
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'
See also