From 03f801c7ffb7e74fc12690ede9468769f92f2f68 Mon Sep 17 00:00:00 2001 From: Ian Strachan Date: Sat, 27 Oct 2012 15:37:02 +0100 Subject: [PATCH] Failing unit test for issue #324 --- rest_framework/tests/models.py | 4 ++++ rest_framework/tests/serializer.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/rest_framework/tests/models.py b/rest_framework/tests/models.py index 0ee18c697..453dfc2cb 100644 --- a/rest_framework/tests/models.py +++ b/rest_framework/tests/models.py @@ -111,3 +111,7 @@ class BlogPost(RESTFrameworkModel): class BlogPostComment(RESTFrameworkModel): text = models.TextField() blog_post = models.ForeignKey(BlogPost) + +# Model for issue #324 +class BlankFieldModel(RESTFrameworkModel): + title = models.CharField(max_length=100, blank=True) diff --git a/rest_framework/tests/serializer.py b/rest_framework/tests/serializer.py index 67c97f0ff..afb7f3dbc 100644 --- a/rest_framework/tests/serializer.py +++ b/rest_framework/tests/serializer.py @@ -436,3 +436,19 @@ class ManyRelatedTests(TestCase): } self.assertEqual(serializer.data, expected) + + +# Test for issue #324 +class BlankFieldTests(TestCase): + def setUp(self): + + class BlankFieldModelSerializer(serializers.ModelSerializer): + class Meta: + model = BlankFieldModel + + self.serializer_class = BlankFieldModelSerializer + + def test_create_blank_field(self): + data = {'title': ''} + serializer = self.serializer_class(data) + self.assertEquals(serializer.is_valid(), True)