-
Notifications
You must be signed in to change notification settings - Fork 0
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
Notification Enum Field 수정 #32
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@jaeyoungleeee
수고하셨습니다!
Python native인
Enum
과 어떤 차이가 있는 걸까요?기존에 구현해주신 Enum을 iterate하면서 직접 field 의 choice 값을 넣어주는 구현해주시는 것도 문제가 없어 보였는데, 왜 바꿔주셨는지 궁금하네요!
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.
@keetae423
오 좋은 리뷰 감사합니다!
우선 기존에 issue(#29) 로 정리해둔 부분의 근본 원인이 바로, enum field 를 rest_framework 에서 제대로 serialize 해주지 못했던 것으로 확인했습니다.
이를 위해, 애초에 choice 를 넣어둘 때, choice element 의 쌍을 (str, str) 으로 넣어주는 것들도 방법이지만, 이 경우 enum 을 쓰는 것이 무의미해진다고 판단하였습니다. singleton 으로서의 enum 의 기능을 상실하고, 결국 literal 이 되기 때문입니다. serialize 를 해줄 때만 저절로 enum 으로 해주는 선택지들도 있긴 했습니다만 (다른 외부 라이브러리 사용), star 수를 확인했을 때 범용적으로 사용되는 라이브러리는 별로 없더라고요.
다행히 찾던 중 django 에서 defaut 로 enum 의 usecase 와 유사한 상황에서 쓸 수 있는 TextChoices 를 제공하는 것을 확인했습니다. (https://docs.djangoproject.com/en/dev/ref/models/fields/#enumeration-types)
하여, 이 부분을 적용하고자 했습니다!