Do not check model_field's attributes if it is None

This commit is contained in:
Emanuele Pucciarelli 2014-03-28 19:42:46 +01:00
parent 04315c12af
commit ab5082d15c

View File

@ -828,14 +828,14 @@ class ModelSerializer(Serializer):
if model_field:
kwargs['required'] = not(model_field.null or model_field.blank)
if not model_field.editable:
kwargs['read_only'] = True
if not model_field.editable:
kwargs['read_only'] = True
if model_field.verbose_name is not None:
kwargs['label'] = model_field.verbose_name
if model_field.verbose_name is not None:
kwargs['label'] = model_field.verbose_name
if model_field.help_text is not None:
kwargs['help_text'] = model_field.help_text
if model_field.help_text is not None:
kwargs['help_text'] = model_field.help_text
return PrimaryKeyRelatedField(**kwargs)