1
我有这个型号:Django的多对多怀疑
class Comment(models.Model):
text = models.TextField(max_length = 300)
author = models.ForeignKey(User)
timestamp = models.DateTimeField(auto_now_add = True)
class UserProfile(models.Model):
user = models.ForeignKey(User, unique = True)
comments = models.ManyToManyField(Comment)
class Product(models.Model):
title = models.CharField(max_length = 30)
comments = models.ManyToManyField(Comment)
我知道有django.contrib.comments
但我现在写我自己的评论系统。
UserProfile和Product对象都可以有一个注释列表。 它在逻辑上是否正确?
我的疑问是:一个ManyToManyField指:
- 对象A已经许多对象B,所以对象B已经许多对象A
- 或许多对象A具有许多对象乙?
哪一个这是正确的句子?因为如果它是第一个,我的模型布局是错误的,因为(例如)产品有很多评论,但评论没有很多产品。
你能澄清我的疑问吗?