事件= Event.objects.filter(ORG = request.org).select_related( “event_def”, “位置”, “空间”)Django的 - 如何从多个模型
,我也得到smthing获取所需数据这样
1对象
阿拉木图夜#some event_def
内 - >萨里沙阿尔卡#location
内的位置 - > 7号馆#place
里面的地方 - > 3мая1991г. 0点00分00秒#Event
第二对象
阿拉木图晚#some event_def
内 - >欧米茄#location
内的位置 - >霍尔2 #place
内部发生 - > 6мая1991 г. 0点00分00秒#Event
我需要一个event_def和内部多重locations..etc
事件模型
org = models.ForeignKey(Organization)
event_def = ChainedForeignKey(EventDef,
chained_field = "org",
chained_model_field = "org",
show_all = False,
auto_choose = True
)
location = ChainedForeignKey(Location,
chained_field = "org",
chained_model_field = "org",
show_all = False,
auto_choose = True
)
space = ChainedForeignKey(Space,
chained_field = "location",
chained_model_field = "location",
show_all = False,
auto_choose = True
)
time = models.DateTimeField()
enabled = models.IntegerField(choices = ns.FULL_ENABLE_STATUSES, default = ns.ENABLED_STATUS)
objects = EnableDisableManager()
请你可以发表你的'Event'模型代码在这里? –
如果组织和位置是变量,则不应使用引号。目前你正在使用它们作为字符串。 –