想象一下运营商,数据,语音的模式。数据计划和语音计划包含外键(载波)。现在,由于有些数据计划只能用于某些语音计划,数据计划模型包含许多字段(语音计划)。但是,它列出了所有可用运营商的所有语音计划(在Django admin中)。如何过滤同一运营商的语音计划?你知道吗
class Carrier(models.Model):
# bunch of attributes
#...
class Voice_plan(models.Model):
# bunch of attributes
carrier = ForeignKey(Carrier)
#...
class Data_plan(models.Model):
...
carrier = ForeignKey(Carrier)
# if not available for all voice plans
for_voice_plans = ManyToManyField(Voice_plan) # should be for those voice plans that share the same carrier...
目前没有回答
相关问题 更多 >
编程相关推荐