0
我不能爲了得到找到Django的OMR的有效方法:(原始查詢也未嘗不可)問題具有複雜的Django連接查詢
的這使得分析其中Sites.sitename(Analysi_Items.name ='somename'和Analysis_Items.value ='somevalue')和(Analysi_items_name ='somename'和Analysis_Items.value ='somevalue')和(Analysis_items.name ='somename'和Analysis_Items.value ='somevalue')。
class Sites(models.Model):
region = models.CharField(max_length=1000)
province = models.CharField(max_length=1000)
sitename = models.CharField(max_length=1000, primary_key=True)
class Meta:
verbose_name_plural = "Sites"
def __unicode__(self):
return self.sitename
class Analysis_Items(models.Model):
code = models.ForeignKey('Analysis')
name = models.CharField(max_lenght=100)
value = models.CharField(max_length=20)
class Meta:
verbose_name_plural = "Analysis Type"
class Analysis(models.Model):
date = models.DateField()
site = models.ForeignKey('Sites')
def __unicode__(self):
return str(self.date)
class Meta:
verbose_name_plural = "Analysis"
希望這已經夠清楚了。先謝謝你!
謝謝!似乎工作! – Lessfoe