mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-10-22 19:54:50 +03:00
Improved ValueError msg
This commit is contained in:
parent
04703dca8a
commit
9d8b176374
|
@ -1094,8 +1094,7 @@ class ModelSerializer(Serializer):
|
||||||
for field_name in declared_fields.keys():
|
for field_name in declared_fields.keys():
|
||||||
if field_name in info.relations and info.relations[field_name].to_many and declared_fields[field_name].default is None:
|
if field_name in info.relations and info.relations[field_name].to_many and declared_fields[field_name].default is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"The field '{field_name}' on serializer '{self.__class__.__name__}' is a ManyToMany field and cannot have a default value of None. "
|
f"The field '{field_name}' on serializer '{self.__class__.__name__}' is a ManyToMany field and cannot have a default value of None."
|
||||||
"Please set an appropriate default value, such as an empty list, or remove the default."
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for field_name in field_names:
|
for field_name in field_names:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user