JamesO is correct - it looks like your Category.articles field has a through relationship. Assuming that your models at least resemble the following
class Article(models.Model):
name = models.CharField(max_length=128)
class Category(models.Model):
name = models.CharField(max_length=128)
articles = models.ManyToManyField(Article, through='Membership')
class Membership(models.Model):
article = models.ForeignKey(Article)
category = models.ForeignKey(Category)
author = models.CharField()
then to add an Article
to a Category
you must
m = Membership(article=article, category=category, author="Dan TM")
m.save()
Note - we can't tell what the through
field is called, so Membership
is a guess, inspired by the django docs
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…