﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26362	Manually changing the parent of a child model is silently failing.	Keith Hostetler	Paulo	"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
}}}
"	Bug	closed	Database layer (models, ORM)	1.8	Normal	fixed			Accepted	1	0	0	0	0	0
