我是Django的新手,我遇到了ManyToMany關係的一些問題。 我在BLASTN automatisation工作,這裏有我的課:Django ManyToManyField在Sqlite3中不存在
class Annotation(models.Model):
sequence = models.IntegerField()
annotation = models.TextField()
start = models.IntegerField()
end = models.IntegerField()
class Blast(models.Model):
sequence = models.ManyToManyField(Annotation, through="AnnotBlast")
expectValue = models.IntegerField()
class AnnotBlast(models.Model):
id_blast = models.ForeignKey(Blast, to_field="id")
id_annot = models.ForeignKey(Annotation, to_field="id")
class Hit(models.Model):
id_hit = models.ForeignKey(Blast, to_field="id")
length = models.IntegerField()
evalue = models.IntegerField()
start_seq = models.IntegerField()
end_seq = models.IntegerField()
在視圖中,我想通過這麼多從模型的其餘部分訪問註釋的數據很多字段,然後根據應用濾鏡形成。但是,當我做了syncdb
,爆破類的「序列」字段消失:
在SQLITE3:
.schema myApp_blast
CREATE TABLE "myApp_blast" (
"id" integer not null primary key,
"expectValue" integer not null
);
所以我不能在此表中,因爲我想加載數據。我不明白爲什麼這個字段在syncdb中消失。我怎樣才能將第一類鏈接到其他類(然後能夠合併模板中的數據)?
謝謝你,你的評論對我有幫助。我真的認爲ManyToManyField是數據庫中的一列...謝謝丹尼爾! –