Re: setting ForeignKey/OneToOneField in pre_save is not effective - bug?

2019-09-22 Thread Martín Massera
Ok I found the source of the problem, which is the order of assigning and saving the b object. Saving first and assigning later works: b = B() b.save() instance.b = b On Sunday, September 22, 2019 at 10:53:32 AM UTC-3, Martín Massera wrote: > > Hi guys I'm posting this here before creating a

setting ForeignKey/OneToOneField in pre_save is not effective - bug?

2019-09-22 Thread Martín Massera
Hi guys I'm posting this here before creating a ticket, not sure if this is intended behavior but it looks like a bug to me. I have a pre_save method that populates a non-nullable OneToOneField in case it is not set at save time. class A(Model): b = models.OneToOneField(B, on_delete=CASC