Re: Saving ManyToMany relationships in custom manipulator

2006-08-30 Thread Russell Keith-Magee
On 8/30/06, Nowell <[EMAIL PROTECTED]> wrote: I believe that the correct way to accomplish this is:temp = Message(...)temp.save()temp.teams = Team.objects.filter(id__in=data.getlist('teams'))Notice you need to use the getlist() function to return a list of the M2M selections, the previous code

Re: Saving ManyToMany relationships in custom manipulator

2006-08-30 Thread Nowell
I believe that the correct way to accomplish this is: temp = Message(...) temp.save() temp.teams = Team.objects.filter(id__in=data.getlist('teams')) Notice you need to use the getlist() function to return a list of the M2M selections, the previous code will return only the last element.

Re: Saving ManyToMany relationships in custom manipulator

2006-08-24 Thread James Mulholland
Russ and Ivan -- thanks very much for your help! I'd spent several hours searching for info and could only find details of how to do it for old versions. Thanks again. -- James --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Saving ManyToMany relationships in custom manipulator

2006-08-24 Thread Ivan Sagalaev
Russell Keith-Magee wrote: > temp = Message(...) > temp.save() > temp.teams = Team.objects.filter(id__in=data['teams']) > > i.e., there is no need to iterate through the data (which isn't really > efficient, since every add is a separate db operation). Instead, you can > assign an iterable to

Re: Saving ManyToMany relationships in custom manipulator

2006-08-23 Thread Ivan Sagalaev
James Mulholland wrote: > temp.set_teams(data['teams']) > temp.save() This looks like 0.91 syntax that was changed in 'magic-removal' process. Now it should look like this: temp = Message(...) temp.save() for id in data['teams']: temp.teams.add(Team(id)) BTW,

Re: Saving ManyToMany relationships in custom manipulator

2006-08-23 Thread James Mulholland
Does nobody have any ideas about this?!? I stumbled across a link which tells part of the story, so I now think it's more correct to use this: def save(self, data): temp = Message( contact_type = data['contact_type'], mobile_number = data['mobile_number'],