Hi Roald,

Am 20.09.2011 um 15:52 schrieb Roald de Vries:

> Hi all,
> 
> Is there a fundamental reason that I'm missing (other than "nobody's taken 
> the trouble of writing it") that I can't do the following? If there isn't 
> I'll create a ticket for it.

> 
>    class R(Model):
>        user = ForeignKey(User)
>        my_model = ForeignKey('MyModel')
>        comment = CharField(max_length=100, blank=True)
> 
>    class MyModel(Model):
>        users = ManyToManyField(User, through=R, null=True)
> 
>    m = MyModel.objects.create()
>    u = User.objects.create_user('roald', 'downa...@gmail.com', 'password')
> 
> 
>    # these things I can't do:
>    m.users.add(u)
>    m.users.add(u, comment='Blablabla')

https://docs.djangoproject.com/en/1.3/topics/db/models/#intermediary-manytomany

You can't use add() when specifying the intermediate model. You would have to 
check all fields of the intermediate model and make sure all of them have 
defaults or are allowed to be null. It might not be worth the trouble of 
implementing it.

Cheers,
Stephan

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to