django m2m自包含

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

0 TrackBacks

Listed below are links to blogs that reference this entry: django m2m自包含.

TrackBack URL for this entry: http://mt.khsing.net/cgi-bin/mt-tb.cgi/59

Leave a comment

About this Entry

This page contains a single entry by Guixing published on February 10, 2009 3:12 PM.

大裤叉配楼火灾 was the previous entry in this blog.

备份很重要 is the next entry in this blog.

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