Django REST框架:POST时出现额外字段 raise 错误from django.core.exceptions import ValidationError class...
(most recent call last): File "/home/tim/code/django/tests/forms_tests/tests/test_error_messages.py", line 169, in test_booleanfield self.assertFormErrors(['REQUIRED'], f.clean, '') File "/home/tim/code/django/tests/forms_tests/tests/test_error_messages.py", line 23, in assertForm...
(Maybe I should have run this in django shell, but we can still see that ValidationError got raised.)trunk rev 6563>>> import django.newforms as forms >>> class MyForm(forms.Form): ... bfield = forms.BooleanField(required=True) ... >>> f = MyForm({}) >>> f.is_valid() True...
Django allows this to be done by overriding ModelAdmin.save_model(), for example, which I think serves a similar role to the save(commit=False) idiom. Therefore, as mentioned, an IntegrityError isn't an issue with Django, but rather a result of incorrect or incomplete configuration. Closing...