#mezzanine中BlogPost类的定义class BlogPost(Displayable, Ownable, RichText, AdminThumbMixin): """ A blog post. """ categories = models.ManyToManyField("BlogCategory",#多对多,在BlogPost实例中不会出现 verbose_name=_("Categories&q…
转自:http://luozhaoyu.iteye.com/blog/1510635 对于第一次碰到django这样类activerecord的ORM,初学者可能比较疑惑的是ManyToManyField这个字段.老鸟可以绕开,这里拿djangobook没有说明的地方来仔细解释下. from django.db import models class Publisher(models.Model): name = models.CharField(max_length=30) address =…
示例: from django.db import models class Person(models.Model): name = models.CharField(max_length=50) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership', through_fields=('gro…