Hello all,

I started a project way back in the days of Django 1.4.  I am trying to 
upgrade to version 1.6 to make use of some new features.

Anyway, I am coming across this curious change.  Its probably meant to be a 
fix rather than a bug, but its causing huge issues with my code and I did 
not find anything that I thought dealt with it in the release notes, nor 
anybody else mentioning it in my Googles.

Take a very simple Parent->Child relationship:
class TestModel(models.Model):
    pass
 
class TestModelChild(models.Model):
    parent = models.OneToOneField(TestModel)

Now run this simple code
parent = TestModel()
child = TestModelChild(parent=parent)

print parent.testmodelchild

In Django 1.4, the final line would raise an exception as the parent model 
does not have any reference to the child at this point
In Django 1.6, the parent can immediately see the "child" instance.  Its 
already there

Seems logical, and I'm guessing necessary for the new transaction model, 
but as I said, causing huge problems and I can't find anything to warn me 
of it.  Wasn't sure whether to ask how to fix it, report it as a bug or 
ignore it.  Thought I'd post here, maybe someone has a suggestion?

BTW, the reason its causing me issues specifically?
I have one view with a two ModelForms, one for the parent, one for the 
child, and I initialize them like so:

form_parent = TestModelForm(request.POST, instance=parent)
form_child = TestModelForm(request.POST, instance=child)
form_parent.save()
form_child.save()

form_parent.save() causes an exception as its save function is overridden 
and does some work on the child if it exists.  In 1.4 it didn't exist yet 
on first save of the parent.  In 1.6 the child exists even though it really 
shouldn't yet.  There are many solutions to this and I could fix this case 
easily but my code base is so huge at this point and I've used this process 
a lot, I have no confidence in upgrading from 1.4 if this is the case.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2cffb612-7a20-4402-9b27-2b0af2f73e13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to