Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
soerface wants to merge4 commits intoencode:masterfromsoerface:doc-extra-actions-serializer-class
Closed

Improve documentation regarding serializer class on extra actions.#6410

soerface wants to merge4 commits intoencode:masterfromsoerface:doc-extra-actions-serializer-class

Conversation

@soerface
Copy link

The documentation does currently not describe how to use a customserializer_class with 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 theserializer_class kwarg in his PR#5605 (comment)

ulgens and aehlke reacted with thumbs up emojiulgens reacted with hooray emojiulgens reacted with heart emojiulgens reacted with rocket emoji
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
Copy link
Contributor

Hi,

Thank you for the contribution.
The issue with this PR is that it's specific toserializer_class while it could also cover throttling, permissions and so on.
I'd rather see something more opened such as "it takes as arguments the class properties such as serializer_class"

…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
Copy link
Author

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 theserializer_class argument (and useself.get_serializer() if I'm not mistaken, see review). I think that the example caused the confusion with meand others trying to use a custom serializer class.

Copy link
Collaborator

@carltongibsoncarltongibson left a 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)
Copy link
Collaborator

@carltongibsoncarltongibsonJan 22, 2019
edited
Loading

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
Copy link
Author

soerface commentedJan 23, 2019
edited
Loading

The kwarg is necessary, regardless of usage inside the function. Without the kwarg, the generated doc will show theUserSerializer form, not thePasswordSerializer form. That is the reason why I had trouble with understanding the decorator, I didn't knew how to change the form.

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
Copy link
Collaborator

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.

@stale
Copy link

stalebot commentedJul 31, 2022

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.

@stalestalebot added the stale labelJul 31, 2022
@stalestalebot closed thisAug 13, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@carltongibsoncarltongibsoncarltongibson left review comments

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@soerface@xordoquy@carltongibson

[8]ページ先頭

©2009-2025 Movatter.jp