tomchristie/django-rest-framework — pull request #1670 by pySilver (2014-06-29 14:32:37+00:00)
Title: Fixes fields behaviour against empty values (null, None, etc)

This PR fixes problems described at #1570, #1665 and #1663

In short:
- CharField should return "" (empty string) for empty values like django.form CharField does. Since django model prevents charfield to be nullable https://docs.djangoproject.com/en/dev/ref/models/fields/#null we can assume this is correct behaviour for DRF.
- ModelField throws error if value is None and bounded model field is not nullable. (django docs says it is our responsability to make this check, thats why it is here, otherwise it'd result int IntegrityError which is not usefull for any api client.) See: https://code.djangoproject.com/ticket/22921
- RelatedField sets proper value for nulls depending on state of self.many, so it follows same logic as ModelChoiceField and ModelMultipleChoiceField

All tests are green.