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
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.
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
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
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,
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'],
6 matches
Mail list logo