开发者

Django: ForeignKey() or ManyToMany() in this case? Or, other?

I have a model that is something like this:

class ReturnAuthorization(models.Model):
    custom_id = models.CharField(max_length=40)

class RMAAPILog(models.Model):
    return_authorization = models.ForeignKey(ReturnAuthorization)

If I were to delete() a return authorization, I can't have it delete all the RMAAPILog()s that are related to it. In this cas开发者_运维问答e they get deleted. There can be many attempts to get an RMA from the outside API (so many RMAAPILog()s per ReturnAuthorization(), but there can only be one ReturnAuthorization() for each RMAAPILog() of course because it's a log of an attempt to authorize a specific ReturnAuthorization(). What would be the better way to do this, or am I thinking of it all wrong?


Related SO question: How do I create a Django model with ForeignKeys which does not cascade deletes to its children?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜