阅读背景:

Django模型与多个模型的关系

来源:互联网 

Suppose there is an abstract model CarOwner: whereas a Person or a Business can be a CarOwner. In addition a Car with a certain VIN can belong (relate) to either a Person or a Business, but not both (mutually exclusive case). At the very end of the following code I presented two possibilities (see comments in the code "# 1. SHOULD I HAVE THIS???" and "# 2. ...OR SHOULD I HAVE THIS???"). In the first possibility a Many-to-One relationship is established to an abstract model and I am not sure if this is the right way. In the second case two relationships are established and I am not sure if that is correct either, especially it is not clear how to make them mutually exclusive. So which one is right and if neither, please, provide the right answer if you could. Thanks. Suppose there is an abstract model CarOwner: wh




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: