#35127: Model.full_clean() errors with GeneratedField
-------------------------------------+-------------------------------------
               Reporter:  Claude     |          Owner:  nobody
  Paroz                              |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  5.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35127>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d1dabed93-a265c285-e846-4627-9a8a-6d3701f9b05a-000000%40eu-central-1.amazonses.com.

Reply via email to