Hi Tom,
Am 2013-04-25 18:53, schrieb Tom Evans:
> Yes, this is correct, when you assign an object to a foreign key, it
> must already be saved so that it has an id in order to persist in the
> database.
It's very good to hear this, thank you very much for your reply!
No, I'm using 1.5.1 (sorry for not having mentioned this earlier), but didn't get any
exception, exactly as shown in my original mail.
Thanks to your pointers into the code, I tested a bit more, and it seems that my case is
not handled in class SingleRelatedObjectDescriptor, but in class
ReverseSingleRelatedObjectDescriptor -- which I don't understand, but can easily trigger
the assertion in line
https://github.com/django/django/blob/1.5.1/django/db/models/fields/related.py#L405
by a statement like ma.vbp = SomeOtherClass()
The __set__ method in ReverseSingleRelatedObjectDescriptor does not seem to have an
equivalent to the check in SingleRelatedObjectDescriptor, so this explains why I could
do the original assignment ma.vbp = Vorblendplan()
Best regards,
Carsten