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 befo

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

weak object has gone away

2016-06-09 Thread Martín Massera
Hi ! Every 6-12 months it happens that all my views start failing with this error: TypeError: weak object has gone away There are some caches here and there and it seems to me that there must be a problem with them, but I dont know since this doesnt happen when I develop, it only happens