Re: Checking if ManyToManyField is empty in pre_save function

2006-05-01 Thread Ivan Sagalaev
Luke Plant wrote: >It would be possible to get Django to throw an exception in this case. >What do people think about that? > > I think it makes sense. As well as documenting that though dependent objects (both M2M and 12M) look like they are belong to the parent they really can't be proces

Re: Checking if ManyToManyField is empty in pre_save function

2006-05-01 Thread Luke Plant
On Monday 01 May 2006 12:08, Dagur wrote: > On further inspection I found out > that the "authorised" field is set to all users before saving but is > empty after saving. > > >>> t = Topic() > >>> t.authorised.count() > > 2773L > > >>> t.save() > >>> t.authorised.count() > > 0L > > Is this the de

Checking if ManyToManyField is empty in pre_save function

2006-05-01 Thread Dagur
Hi, I have a ManyToManyField called "authorised" (which is supposed to be a list of users) and a BooleanField called "is_private" which should be set to false if there are no users in "authorised" so I did this: def save(self): if self.authorised.count() == 0: self.is_priv