0
class UserProfile(models.Model):
user = models.ForeignKey(User, unique = True, related_name = 'user')
likes = models.ManyToManyField(Product, null = True, blank = True)
class Product(models.Model):
user = models.ForeignKey(User)
price = models.FloatField(default = 0)
p1 = Product.objects.get(pk = 1)
我想指望有多少次p1
包含在likes
領域中的所有用戶配置的對象。
怎麼樣?
謝謝。還有'p1.userprofile_set.count()' –