Hi,
Consider a model and a simple test for the model.

class Project(models.Model):
    name = models.CharField(maxlength = 255)
    parent = models.ForeignKey('self', null = True)

class ProjectTests(unittest.TestCase):
    def testCreateProjectAndSubProject(self):
        project = Project(name = "aProject")
        subProject = Project(name = "aSubProject", parent = project)

        project.save()
        self.assert_(project.id) # Passes

        subProject.save()
        self.assert_(subProject.parent) # Fails

It seems that even though the Parent object gets saved and has an id
(see the line in the test with the comment "Passes") the parent object
is None when I access it through the child. It seems that parent and
child.parent point to two different objects even though the original
parent was supplied to the child's constructor.

What is happening here?

Thanks,
Manoj


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to