#26362: Manually changing the parent of a child model is silently failing.
----------------------------------------------+--------------------
Reporter: Macainian | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
To be honest, I have no idea if it is supposed to be allowed to set the
parent via the parent_ptr, but it isn't working. If it isn't allowed, it
should be reporting an error.
Example:
{{{
class Parent(models.Model):
field1 = models.TextField(default="abc")
class Child(Parent):
field2 = models.TextField(default="abc")
def change_parent():
child = Child.objects.get(id=1)
new_parent = Parent.objects.create()
print child.id # Prints 1
print child.parent_ptr.id # Prints 1
print new_parent.id # We'll say it is number 5
child.parent_ptr = new_parent
print child.id # Prints 1
print child.parent_ptr.id # Prints 5
child.save()
print child.id # Prints 1
print child.parent_ptr.id # Prints 1
}}}
This applies to the update function as well. I tried:
{{{
Child.objects.filter(id=1).update(parent_ptr=new_parent)
child = Child.objects.get(id=1)
print child.id # Prints 1
print child.parent_ptr.id # Prints 1
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26362>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.cc459a9bc5c6844560a6169000002d08%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.