且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

双重外键在Django?

更新时间:2023-01-25 20:12:54

听起来像是一个多态关联。也许你可以用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.