Re: A ManyToMany Field question.

2009-02-11 Thread khsing
Yes, I am work on a python 2.3 environment now. Thanks a lots. I will import set datatype. On Thu, Feb 12, 2009 at 10:24 AM, Alex Gaynor wrote: > datatype -- A man live in jail and want to break. http://blog.khsing.net --~--~-~--~~~---~--~~ You received this

Re: A ManyToMany Field question.

2009-02-11 Thread Alex Gaynor
On Wed, Feb 11, 2009 at 9:20 PM, khsing wrote: > > Yes, that was I wanted. This case like I know you, but you don't know me. > > I notice when symmetrical argument added, a group object has > related_name_set object, so I can write code like this. > > def all_group(user): >groups = [] >fo

Re: A ManyToMany Field question.

2009-02-11 Thread khsing
Yes, that was I wanted. This case like I know you, but you don't know me. I notice when symmetrical argument added, a group object has related_name_set object, so I can write code like this. def all_group(user): groups = [] for group in user.group_set.all(): if not group in group

Re: A ManyToMany Field question.

2009-02-11 Thread Alex Gaynor
On Wed, Feb 11, 2009 at 9:06 PM, khsing wrote: > > Alex, thank you very much. > > I find if g1 belong g2, g2 will belong g1 automatically, but that is not > right. > > should I rewrite models like this one? > > groups = models.ManyToManyField('self', symmetrical=False) > > > On Wed, Feb 11, 2009

Re: A ManyToMany Field question.

2009-02-11 Thread khsing
Alex, thank you very much. I find if g1 belong g2, g2 will belong g1 automatically, but that is not right. should I rewrite models like this one? groups = models.ManyToManyField('self', symmetrical=False) On Wed, Feb 11, 2009 at 10:40 PM, Alex Gaynor wrote: > > > On Wed, Feb 11, 2009 at 2:29

Re: A ManyToMany Field question.

2009-02-11 Thread Alex Gaynor
On Wed, Feb 11, 2009 at 2:29 AM, khsing wrote: > > class user(models.Model): >username = models.CharField(max_length=50) > > class group(models.Model): >groupname = models.CharField(max_length=50) >users = models.ManyToManyField(user) >groups = models.ManyToManyField('self') > > t

Re: A ManyToMany Field question.

2009-02-10 Thread khsing
class user(models.Model): username = models.CharField(max_length=50) class group(models.Model): groupname = models.CharField(max_length=50) users = models.ManyToManyField(user) groups = models.ManyToManyField('self') there are my models. I have no idea to get a complete group li

Re: A ManyToMany Field question.

2009-02-09 Thread khsing
Alex, thanks, now it work. now have a new problem is may a group can contain itself, this will be a loop. how to avoid this condition? On Tue, Feb 10, 2009 at 11:28 AM, Alex Gaynor wrote: > > > On Mon, Feb 9, 2009 at 10:18 PM, khsing wrote: >> >> I want design a group that can contain other

Re: A ManyToMany Field question.

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 10:18 PM, khsing wrote: > > I want design a group that can contain other groups, and one group can > belong many groups. > > I write such code below, but not right. > > class Group(models.Model): >groups = models.ManyToManyField(Group) > > any suggestion? > > or how to

A ManyToMany Field question.

2009-02-09 Thread khsing
I want design a group that can contain other groups, and one group can belong many groups. I write such code below, but not right. class Group(models.Model): groups = models.ManyToManyField(Group) any suggestion? or how to design such a group. thanks. -- A man live in jail and want to b