双重外键在Django? [英] Double Foreign Key in Django?
本文介绍了双重外键在Django?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,如果我有表:audio,overlay,html
和表:timeline_item它有一个字段ID和一个字段类别,指定音频,覆盖,或HTML ...
有谁知道我将如何在Django建模?或者甚至是可能的?
解决方案
听起来像是一个多态关联。也许你可以用Django的泛型关系解决你的问题,使用 ContentTypes 框架。
Is there anyway to model double foreign keys in Django?
For instance if I had tables: audio, overlay, html and the table: timeline_item which has a field id, and a field category which specifies audio, overlay, or html...
Does anyone know how I would go about modeling this in Django? or if it's even possible?
解决方案
Sounds like a polymorphic association. Maybe you can solve your problem with Django's generic relations using the ContentTypes framework.
这篇关于双重外键在Django?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文