-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🌐 Add Korean translation for docs/ko/docs/tutorial/body-updates.md
#3120
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,98 @@ | ||||||||||
# 본문 - 업데이트 | ||||||||||
|
||||||||||
## `PUT`을 이용한 업데이트 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
항목을 업데이트 하기 위해 <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT" class="external-link" target="_blank">HTTP `PUT`</a>을 사용할 수 있습니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
`jsonable_encoder`를 사용하여 입력 데이터를 JSON(예: NoSQL 데이터베이스 데이터)으로 저장 가능한 데이터로 변환할 수 있습니다. 예를 들면, `datetime` 타입을 `str`로 변환하게 됩니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
```Python hl_lines="30-35" | ||||||||||
{!../../../docs_src/body_updates/tutorial001.py!} | ||||||||||
``` | ||||||||||
|
||||||||||
`PUT`은 기존 데이터를 대체하기 위한 항목을 수신하는 데 사용됩니다. | ||||||||||
|
||||||||||
### 데이터 대체 경고 | ||||||||||
|
||||||||||
본문이 포함된 `PUT`을 사용하여 `bar` 항목을 업데이트 하려면: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
```Python | ||||||||||
{ | ||||||||||
"name": "Barz", | ||||||||||
"price": 3, | ||||||||||
"description": None, | ||||||||||
} | ||||||||||
``` | ||||||||||
|
||||||||||
이미 저장된 속성 `"tax": 20.2`를 포함하지 않기 때문에 기본값 `"tax": 10.5`를 사용합니다. | ||||||||||
그리고 데이터는 `10.5`라는 "새로운" `tax`로 저장됩니다. | ||||||||||
|
||||||||||
## `PATCH`를 이용한 부분 업데이트 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
데이터를 부분적으로 업데이트 하기; 위해 HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH" class="external-link" target="_blank">HTTP `PATCH`</a> 를 사용할 수도 있습니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
즉, 업데이트하려는 데이터만 보내고, 나머지는 그대로 둘 수 있습니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
!!! Note | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
일반적으로 `PATCH`보다 `PUT`이 더 일반적으로 사용되고, 잘 알려져 있습니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it need to indent? |
||||||||||
|
||||||||||
그리고 많은 팀이 부분 업데이트를 위해서도 `PUT`만 사용합니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
무엇을 사용하든 FastAPI에서는 어떠한 제한도 없습니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
하지만 이 가이드는 각 메소드가 어떻게 사용되는지를 보여줍니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
### Pydantic의 `exclude_unset` 매개 변수 사용 | ||||||||||
|
||||||||||
Pydantic 모델의 `.dict()`에서 `exclude_unset` 매개변수를 사용하는 것은 부분 업데이트를 위해 매우 유용합니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
이것은 `item.dict(exclude_unset=True)`와 같습니다. | ||||||||||
|
||||||||||
이렇게 하면 기본값을 제외하고 `item` 모델을 만들 때 설정한 데이터만 있는 `dict`가 생성됩니다. | ||||||||||
|
||||||||||
위 데이터를 사용하여 설정된 데이터(요청에서 전송됨)만으로 `dict`를 생성하고 기본값을 생략할 수 있습니다: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
```Python hl_lines="34" | ||||||||||
{!../../../docs_src/body_updates/tutorial002.py!} | ||||||||||
``` | ||||||||||
|
||||||||||
### Pydantic의 `update` 매개 변수 사용 | ||||||||||
|
||||||||||
이제 `.copy()`를 이용하여 기존 모델의 복사본을 만들고 업데이트 할 데이터가 포함된 `dict`와 함께 `update` 매개변수를 전달할 수 있습니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
예시) `stored_item_model.copy(update=update_data)`: | ||||||||||
|
||||||||||
```Python hl_lines="35" | ||||||||||
{!../../../docs_src/body_updates/tutorial002.py!} | ||||||||||
``` | ||||||||||
|
||||||||||
### 부분 업데이트 요약 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
부분 업데이트를 적용하는 방법을 요약하면: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
- (선택) `PUT` 대신 `PATCH`를 사용합니다. | ||||||||||
- 저장된 데이터를 검색합니다. | ||||||||||
- 위 데이터를 Pydantic 모델에 넣습니다. | ||||||||||
- 위 모델에서 기본값 없는 `dict`를 생성합니다. (`exclude_unset` 사용). | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
- 이렇게 하면 모델에 이미 기본값으로 저장된 값을 재정의하는 대신 클라이언트가 실제로 설정한 값만 업데이트 할 수 있습니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
- 저장된 모델의 복사본을 만들고 수신된 부분 데이터로 속성을 업데이트 합니다. (`update` 매개변수 사용) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
- 복사된 모델을 DB에 저장할 수 있는 형태로 변환합니다. (예를 들면, `jsonable_encoder` 함수를 사용한 JSON 데이터 변환). | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
- 이것은 모델의 `.dict()` 메소드를 다시 사용하는 것과 비슷하지만 값을 JSON으로 변환할 수 있는 데이터 유형(예: `datetime`에서 `str`로 변환)으로 확인(및 변환)합니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
- DB에 데이터를 저장합니다. | ||||||||||
- 업데이트된 데이터 모델을 반환합니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
```Python hl_lines="30-37" | ||||||||||
{!../../../docs_src/body_updates/tutorial002.py!} | ||||||||||
``` | ||||||||||
|
||||||||||
!!! tip | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
실제로 HTTP `PUT` 메소드를 이용하여 이와 동일한 기술을 사용할 수 있습니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Isn't it need to indent? |
||||||||||
|
||||||||||
그러나 이 예제는 이렇게 사용할 수 있다. 정도만 보여주기 위해 만들어졌으므로 `PATCH`를 이용하는 것이 바람직합니다. | ||||||||||
|
||||||||||
!!! note | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
입력 모델의 유효성 검사는 여전히 이뤄집니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Isn't it need to indent? |
||||||||||
|
||||||||||
따라서, 모든 속성을 생략할 수 있는 부분 업데이트를 위해서는 모든 속성이 `Optional`(기본값을 지정하거나 혹은 `None`을 사용)으로 표시된 모델이 있어야 합니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Also, the origin document doesn't use the word |
||||||||||
|
||||||||||
**업데이트**를 위한 모든 `Optional`값이 있는 모델과 **생성**을 위한 `required`값들이 있는 모델과 구별을 위해서는 [Extra Models](extra-models.md){.internal-link target=_blank}에 있는 방법을 이용할 수 있습니다. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check #2017 .