On May 14, 11:20 am, Milan Andric <[EMAIL PROTECTED]> wrote:
> Hello,
>
> My Tutorial model has an author field, which can contain many authors:
>
> class Tutorial(models.Model):
>     ...
>     author = models.ManyToManyField(User,limit_choices_to =
> {'is_staff' :1})
>
> When i try to save :
>
> users=[]
> users.append(User.objects.get(username='joe'))
> users.append(User.objects.get(username='bob'))
> t = Tutorial(author=users, ...)
> t.save()
>
> I get an error:
>
> TypeError: 'author' is an invalid keyword argument for this function
>

A friend on IRC informed me ..

since the object has no ID yet
and an m2m is a link between IDs
t = Tutorial(...everything but author...)
t.save()
t.author.add(user1)

Makes sense, trying ...

Thanks!


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to