Merge pull request #515 from yprez/blank_fields_issue

Fix for #514
This commit is contained in:
Tom Christie 2012-12-29 05:25:43 -08:00
commit 809f5de330
2 changed files with 5 additions and 1 deletions

View File

@ -441,7 +441,7 @@ class ModelSerializer(Serializer):
kwargs['blank'] = model_field.blank
if model_field.null:
if model_field.null or model_field.blank:
kwargs['required'] = False
if model_field.has_default():

View File

@ -751,6 +751,10 @@ class BlankFieldTests(TestCase):
serializer = self.not_blank_model_serializer_class(data=self.data)
self.assertEquals(serializer.is_valid(), False)
def test_create_model_null_field(self):
serializer = self.model_serializer_class(data={})
self.assertEquals(serializer.is_valid(), True)
#test for issue #460
class SerializerPickleTests(TestCase):