I am trying to save sections of a document in a Django application. The model is as follows:
class Section(models.Model): project = models.ForeignKey(Project) parent_section = models.ForeignKey('Section', blank=True, null=True, related_name='child_set') predecessor_section = models.ForeignKey('Section', blank=True, null=True, related_name='predecessor_set') name = models.CharField(max_length=100) text = models.TextField(blank=True, null=True)
I create many sections, bind them (parent_section, predecessor_section) and save them, calling each of my save methods. However, when I look at the table after saving it, parent_section_id and predecessor_section_id are not set, although objects were bound to them before saving.
I assume this is because some parent_section instances do not have an identifier, since their instance has not yet been saved, but using manual transactions cannot solve the problem.
Any thoughts on this?
Cheers, Max
source share