Fix docs typo in Serializers Validators by cheehong1030 · Pull Request #9563 · encode/django-rest-framework (original) (raw)
Description
Pull Request Description
Fix: Correct example for UniqueTogetherValidator in serializer documentation
The example provided for using UniqueTogetherValidator
in the serializer documentation currently uses an IntegerField
for the room_number
field. This is incorrect, as UniqueTogetherValidator
is designed to work with relational fields, not integer fields.
This pull request replaces the IntegerField
with a ChoiceField
for the room_number
field, which is a more appropriate field type for this scenario. This change ensures that the example accurately demonstrates how to use UniqueTogetherValidator
with related fields.
Changes Made:
- In the example code snippet, the
room_number
field has been changed from:
room_number = serializers.IntegerField(choices=[101, 102, 103, 201])
to:
room_number = serializers.ChoiceField(choices=[101, 102, 103, 201])
This minor correction will help users understand how to properly implement UniqueTogetherValidator
in their serializers.
room_number = serializers.IntegerField(choices=[101, 102, 103, 201]) |
---|