On Tue, Sep 20, 2011 at 4:12 PM, Roald de Vries <[email protected]> wrote: > > I don't see how this is different from the create method on the intermediary > model. > > Cheers, Roald > > PS: I found an open ticket on this, > https://code.djangoproject.com/ticket/9475 >
Here is the function definition for add() on related object manager: add(obj1[, obj2, ...]) As you can see, it can be used to add multiple objects to the relationship in one go, and therefore the arguments to this function would need to change to support what you propose. This would require going through the whole deprecation procedure (2/3 major releases before it is gone), and I guess the pain outweighs the gain on that one. create() takes **kwargs, but those arguments relate to the instance being created on the other end of the relationship, there would still be no way to specify non-default values for the intermediate model. You would have to do something similar to passing a defaults dictionary to create(), which then makes it different to how create() on an object manager works, and introduces another field that you would have to do some magic to work around. I guess the main thing is what's the point? The argument is over which of these is prettier: model_a_instance.modelb_set.add(model_b_instance) and Intermediate.objects.create(model_a=model_a_instance, model_b=model_b_instance) Beauty contests in code are rather pointless - the documentation has for a long time said that the latter is the only way you can do it, and most developers are now used to that. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
