Re: Accessing many-to-many relations in save()

2007-10-12 Thread Adam Endicott
> I don't think there's a clean solution to this (as far as making the > Admin work with it). I don't think the admin can make use of a custom > manipulator without hackish code. Bummer, I figured the best I could hope for would be to replace the automatic manipulators to do my bidding after they

Re: Accessing many-to-many relations in save()

2007-10-12 Thread RajeshD
On Oct 12, 1:04 pm, Adam Endicott <[EMAIL PROTECTED]> wrote: > > How about something along these lines (a lazy initialization pattern): > > Well, the point of saving that boolean was so I could do database > queries on it (MyModel.objects.filter(has_m2m_thing=True)). That > wouldn't really work

Re: Accessing many-to-many relations in save()

2007-10-12 Thread Adam Endicott
> How about something along these lines (a lazy initialization pattern): Well, the point of saving that boolean was so I could do database queries on it (MyModel.objects.filter(has_m2m_thing=True)). That wouldn't really work with this lazy initialization pattern, unless I'm missing something. Sor

Re: Accessing many-to-many relations in save()

2007-10-12 Thread RajeshD
> Sure. I'm trying to set a boolean property on the object based on the > existence (or absence) of a ManyToMany relationship. So I originally > thought something like: > > def save(self): > self.has_m2m_thing = bool(self.m2m_relation.count()) > super(MyModel, self).save() > > This works f

Re: Accessing many-to-many relations in save()

2007-10-12 Thread Adam Endicott
> Can you describe generally what you are trying to update in the parent > object when its ManyToMany relationships are changed. Perhaps there's > a way to solve your specific problem without requiring more general > purpose solutions (like Custom Manipulators). Sure. I'm trying to set a boolean

Re: Accessing many-to-many relations in save()

2007-10-12 Thread RajeshD
On Oct 11, 6:54 pm, Adam Endicott <[EMAIL PROTECTED]> wrote: > I've got an app where I'd like to set some properties in an object's > save method based on ManyToMany relationships. Can you describe generally what you are trying to update in the parent object when its ManyToMany relationships ar