On 8/23/06, Ivan Sagalaev <[EMAIL PROTECTED]> wrote:

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))

Another approach:

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 a m2m descriptor, using a filtered QuerySet as the iterable. The m2m relation will contain all the members of the iterable.

Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to