mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
Do not check model_field's attributes if it is None
This commit is contained in:
parent
04315c12af
commit
ab5082d15c
|
@ -828,14 +828,14 @@ class ModelSerializer(Serializer):
|
||||||
if model_field:
|
if model_field:
|
||||||
kwargs['required'] = not(model_field.null or model_field.blank)
|
kwargs['required'] = not(model_field.null or model_field.blank)
|
||||||
|
|
||||||
if not model_field.editable:
|
if not model_field.editable:
|
||||||
kwargs['read_only'] = True
|
kwargs['read_only'] = True
|
||||||
|
|
||||||
if model_field.verbose_name is not None:
|
if model_field.verbose_name is not None:
|
||||||
kwargs['label'] = model_field.verbose_name
|
kwargs['label'] = model_field.verbose_name
|
||||||
|
|
||||||
if model_field.help_text is not None:
|
if model_field.help_text is not None:
|
||||||
kwargs['help_text'] = model_field.help_text
|
kwargs['help_text'] = model_field.help_text
|
||||||
|
|
||||||
return PrimaryKeyRelatedField(**kwargs)
|
return PrimaryKeyRelatedField(**kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user