ergh. Rookie error. Subtle bug in the Job class - see the save override:
def save(self, *args, **kwargs):
if not self.slug:
self.slug = self.job_number
super(Job, self).save(*args, **kwargs)
Note that the call to super is only reachedwhen there is no slug.
The fix is simple:
Ok, I now understand why this happens:
>>> x == j
True
>>> j == x
True
>>> j.findings
'data'
>>> x.findings
u''
https://docs.djangoproject.com/en/dev/ref/models/instances/#eq
"with the same primary key value and the same concrete class are
considered equal. "
(no docs in 1.6, but I presume that
I have run up against this bug before:
https://code.djangoproject.com/ticket/8892
Recently, it was updated to "duplicate of"
https://code.djangoproject.com/ticket/10811
The TL;DR is
Sometimes when you have models with O2O or FK you can lose data if the
models are saved in the wrong order.
I'm
3 matches
Mail list logo