#22921: Model.clean_fields incorrectly skips validation for fields where null
value
is not allowed
-------------------------------------+-------------------------------------
Reporter: silveroff@… | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage:
Severity: Normal | Unreviewed
Keywords: field validation, | Needs documentation: 0
model | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Comment (by pysilver):
Yes, and there are just a few simple tests fails.
I've seen that "Skip validation for empty" many times, and yet many times
I've seen bugs caused by this behaviour... This is just does not feel
right – docs says "use model.full_clean() to make sure model is valid" and
turns out thats not true.
{{{
======================================================================
FAIL: test_abstract_inherited_unique (model_forms.tests.UniqueTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Silver/Projects/Interesting Repos/django-
repo/tests/model_forms/tests.py", line 721, in
test_abstract_inherited_unique
self.assertEqual(len(form.errors), 1)
AssertionError: 3 != 1
======================================================================
FAIL: test_inherited_unique (model_forms.tests.UniqueTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Silver/Projects/Interesting Repos/django-
repo/tests/model_forms/tests.py", line 702, in test_inherited_unique
self.assertEqual(len(form.errors), 1)
AssertionError: 3 != 1
======================================================================
FAIL: test_inherited_unique_together (model_forms.tests.UniqueTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Silver/Projects/Interesting Repos/django-
repo/tests/model_forms/tests.py", line 712, in
test_inherited_unique_together
self.assertEqual(len(form.errors), 1)
AssertionError: 3 != 1
======================================================================
FAIL: test_validation_with_empty_blank_field
(validation.tests.ModelFormsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Silver/Projects/Interesting Repos/django-
repo/tests/validation/tests.py", line 104, in
test_validation_with_empty_blank_field
self.assertEqual(list(form.errors), [])
AssertionError: Lists differ: ['pub_date'] != []
First list contains 1 additional elements.
First extra element 0:
pub_date
- ['pub_date']
+ []
----------------------------------------------------------------------
Ran 7142 tests in 321.586s
FAILED (failures=4, skipped=571, expected failures=8)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22921#comment:6>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/077.6f75856b1cb98759fe892a6c0cf239b6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.