如何在django中查询此(snow flake)数据模式

时间:2015-11-11 21:13:46

标签: python django django-queryset

我想查询django中的雪花数据模式,但无法正确使用。

model.py

cygwin/bin

简短说明:

class City(models.Model):
   city_name =       models.CharField(max_length=30, default='')

class CityTranslations(models.Model):
   language =        models.CharField(max_length=2, default='--')
   city_name_trans = models.CharField(max_length=30, default='')
   city =            models.ForeignKey(City)

class Doctor(models.Model):
   doctor_name =     models.CharField(max_length=30, default='')
   city =            models.ForeignKey(City)

class DoctorTranslations(models.Model):
   language =          models.CharField(max_length=2, default='--')
   doctor_name_trans = models.CharField(max_length=30, default='')
   doctor =            models.ForeignKey(Doctor)

我想:
1.获取所有表格的所有字段(Doctor n:1 City City 1:n CityTranslations Doctor 1:n DoctorTranslations #e.g. german, russian, arabic
2.收到所有医生的清单 3.俄语翻译

所以我试过了:

views.py

selects * from

但这以错误结束

  

select_related()得到了一个意想不到的关键字参数' doctortranslations__language'

感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

Doctor.objects.filter(doctortranslations__language='ru', 
                      city__citytranslations__language='ru')