以下代码将不起作用: class Meta:
unique together = ('code', 'websites') “'unique_together‘引用网站’ManyToManyField‘,但'unique_together’中不允许使用ManyToManyFields” 有没有办法在保持M2M关系的情况下解决这个问题?
我有以下模型,通过指定的连接表,发布需要一个带有作者的m2m,我已经这样做了,但仍然得到错误:publications.workshop: 'staff' is a manually-defined m2m relation through model AuthorsJoinTable, which does not have foreignkeys to Staff and Workshop
publications.technicalreport
要求很简单。登录的用户可以点赞发帖,点赞数增加1。 在这里,我认为下面的模型满足要求,但我想要最好的数据库设计。 或者,可能还有其他最好的选择。 class Post(models.Model): likes = models.ManyToManyField(settings.AUTH_USER_MODEL) 或 class Like(models.Model): user = models.ForeignKey(User)