Results tagged “design”

django m2m自包含

设计一个group,可以包含user也可以包含group。user和group都可以被多个group包含。
class Group(models.Model):
    users = models.ManyToManyField(User)
    groups = models.ManyToManyField('self')
update: ManyToMany对象有一个symmetrical的参数,当为True时的意思是对象间有互相拥有的关系,是双向的,反之为False时就是单向的。
1

Tags

Find recent content on the main index or look in the archives to find all content.