#35127 closed Bug (fixed)
Model.full_clean() errors with GeneratedField
Description ¶
When running full_clean()
on an unsaved model instance, the folllowing error is generated:
AttributeError: Cannot read a generated field from an unsaved model.
Reproducible with following test:
--- a/tests/model_fields/test_generatedfield.py +++ b/tests/model_fields/test_generatedfield.py @@ -177,6 +177,10 @@ class GeneratedFieldTestMixin: with self.assertRaises(IntegrityError): self.base_model.objects.create() + def test_full_clean(self): + m = self.base_model(a=2, b=4) + m.full_clean() + def test_save(self): # Insert. m = self.base_model(a=2, b=4)
Change History (5)
comment:1 by , 14 months ago
Cc: | added |
---|---|
Severity: | Normal → Release blocker |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Note:
See TracTickets
for help on using tickets.
Hello, thank you for your report! And thank you for providing a failing test.
I'm accepting given the failing test and that there is nothing in the docs stating that
full_clean
would not be supported for models including aGeneratedField
s, so while more expert input is needed (adding them as CC), this seems like a valid issue.Regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95