Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Improve documentation regarding serializer class on extra actions.#6410
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
The documentation does currently not describe how to use a custom`serializer_class` with extra actions. The example uses a customserializer without using the seralizer_class attribute, resulting in thegenerated documentation page presenting the wrong form.The author of the feature described the usage of the `serializer_class`kwarg in his pr#5605:#5605 (comment)
xordoquy commentedJan 18, 2019
Hi, Thank you for the contribution. |
…ions." partiallyThis reverts commit963607a partially.It is just a specific example of the already documented "can take extraarguments". The fix for the example was not reverted.
soerface commentedJan 18, 2019
I see, actually, right after the example, it says exactly that. I just didn't get it. Still, I would like to contribute the fix of the example code, passing the |
carltongibson left a comment
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.
The clarification after the example seems good.
I’m not sure about the first addition. It’s perhaps overly complex for the first example.
Maybe passing two kwargs in the second case, i.e. serializer_class as well...?
| serializer_class = UserSerializer | ||
| @action(detail=True, methods=['post']) | ||
| @action(detail=True, methods=['post'], serializer_class=PasswordSerializer) |
carltongibsonJan 22, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Can we then useself.get_serializer() in the method body? (Otherwise the kwarg isn’t doing anything...)
(Although see main comment.)
soerface commentedJan 23, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The kwarg is necessary, regardless of usage inside the function. Without the kwarg, the generated doc will show the I feel that it might be common that extra actions have other inputs than the normal actions. Therefore I think it's a good idea to show correct usage of another serializer. |
carltongibson commentedJan 24, 2019
Hi@soerface. Yes, right. I'm thinking then we should rephrase alittle bit to spell that out. (Note emphasis onlittle.) Happy if you want have a pop at that. If not I'll give it a look over. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The documentation does currently not describe how to use a custom
serializer_classwith extra actions. The example uses a custom serializer without using the seralizer_class attribute, resulting in the generated documentation page presenting the wrong form.The author of the feature described the usage of the
serializer_classkwarg in his PR#5605 (comment)