Skip to content

Boolean field preventing model to be saved #56

Open
@clemyvi

Description

@clemyvi

I am trying to save a model with a boolean field at level 2.

`class Level2(models.Model):
id = models.AutoField(primary_key=True)
level1 = models.ForeignKey(Level1, blank=True, null=True)
is_correct = models.BooleanField(default=False)

class Level3(models.Model):
id = models.AutoField(primary_key=True)
type = models.CharField(max_length = 50, blank=True, null=True)
level2 = models.ForeignKey(Level2, blank=True, null=True)`

if the default value of the boolean field (false here but same when true) is kept, this leads to the following error:

save() prohibited to prevent data loss due to unsaved related object 'level 2'

however once the model has been saved i can change the value of the field without any problem.

Is this a bug or am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions