Hi all,
I have 2 tables, one is A another is B, and B have one FK which contains more than 1 field references to A. The table struct is here:
create table A
(
oid int not null,
types varchar(20) not null,
name varchar(30) null,
color varchar(20) null,
constraint PK_A primary key (oid,types)
)
create table B
(
oid int not null,
types varchar(20) not null,
......
)
alter table alter B add constraint B_FK foreign key (oid,types) references A(oid,types)
The how can i description the ModelB'f FK in Model?
class ModelA(models.Model):
oid = models.IntegerField(max_length=10, primary_key=True)
name = models.CharField(max_length=30, primary_key=True)
....
class ModelB(models.Model):
oid = models.ForeignKey(ModelA, to_field='oid')
types = models.ForeignKey(ModelA, to_field='types')
...
However, this give errors, and not works.
Regards,
Hollandz