diff options
| author | Tom Christie | 2013-01-03 23:17:31 +0000 |
|---|---|---|
| committer | Tom Christie | 2013-01-03 23:17:31 +0000 |
| commit | 6e9865cb71ff45e90020d3d0dc7c40f20c760d2e (patch) | |
| tree | d1323ece42b6e0a6fe365dadd7293e8cedcbf2bd /rest_framework/tests/fields.py | |
| parent | 9b1532b1ea2dcc5d945ebe665093d75bd9d5fa61 (diff) | |
| download | django-rest-framework-6e9865cb71ff45e90020d3d0dc7c40f20c760d2e.tar.bz2 | |
Fix for #446. Note: Also needs applying to other relational types.
Diffstat (limited to 'rest_framework/tests/fields.py')
| -rw-r--r-- | rest_framework/tests/fields.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/rest_framework/tests/fields.py b/rest_framework/tests/fields.py new file mode 100644 index 00000000..147a9229 --- /dev/null +++ b/rest_framework/tests/fields.py @@ -0,0 +1,18 @@ +from django.db import models +from django.test import TestCase +from rest_framework import serializers + + +class NullModel(models.Model): + pass + + +class FieldTests(TestCase): + def test_pk_related_field_with_empty_string(self): + """ + Regression test for #446 + + https://github.com/tomchristie/django-rest-framework/issues/446 + """ + field = serializers.PrimaryKeyRelatedField(queryset=NullModel.objects.all()) + self.assertRaises(serializers.ValidationError, field.from_native, ('',)) |
