Skip to content
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

Make method_name optional in SerializerMethodField #181

Merged
merged 1 commit into from
Apr 1, 2022

Conversation

stianjensen
Copy link
Contributor

@stianjensen stianjensen commented Jan 16, 2022

https://www.django-rest-framework.org/api-guide/fields/#serializermethodfield

You can leave the method_name parameter empty, to get a default value.

For a long time, drf even gave an error when you provided a parameter that matched get_ your field name:
encode/django-rest-framework#2420

@stianjensen
Copy link
Contributor Author

I see that CI is red, but I'm not sure if any of that is caused by this branch, or just the main branch already being red.

@sobolevn
Copy link
Member

Looks like the master is red 😒

https://www.django-rest-framework.org/api-guide/fields/#serializermethodfield

You can leave the method_name parameter empty, to get a default value.

For a long time, drf even gave an error when you provided a parameter that matched `get_` your field name:
encode/django-rest-framework#2420
@stianjensen stianjensen force-pushed the optional-method-name branch from e794812 to 00858e6 Compare March 31, 2022 21:06
@stianjensen
Copy link
Contributor Author

Rebased on master now that it looks green again.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, sorry for the wait!

@sobolevn sobolevn merged commit 8d6ccec into typeddjango:master Apr 1, 2022
@stianjensen stianjensen deleted the optional-method-name branch April 1, 2022 12:10
XF-FW pushed a commit to XF-FW/djangorestframework-stubs that referenced this pull request Apr 7, 2022
https://www.django-rest-framework.org/api-guide/fields/#serializermethodfield

You can leave the method_name parameter empty, to get a default value.

For a long time, drf even gave an error when you provided a parameter that matched `get_` your field name:
encode/django-rest-framework#2420
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants