encode / django-rest-framework

Web APIs for Django. 🎸
https://www.django-rest-framework.org
Other
28.47k stars 6.85k forks source link

Fix docs typo in Serializers Validators #9563

Closed cheehong1030 closed 1 month ago

cheehong1030 commented 1 month ago

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:

This minor correction will help users understand how to properly implement UniqueTogetherValidator in their serializers.

https://github.com/encode/django-rest-framework/blob/d3dd45b3f48856c3513ab1eb5354194fa9898f39/docs/api-guide/serializers.md?plain=1#L236