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

Use a SlugRelatedField to retrieve the app in the Template Message Serializer #218

Open
Sandro-Meireles opened this issue Feb 10, 2023 · 0 comments

Comments

@Sandro-Meireles
Copy link
Collaborator

Problem

This field:

app_uuid = serializers.CharField(write_only=True)

Could be a SlugRelatedField It already does all the work of getting the object from the uuid and handling exceptions. That way it would avoid having to use App.objects.get in the following line:
app = App.objects.get(uuid=validated_data.get("app_uuid"))

Example

An example of how this field is used: https://github.com/weni-ai/weni-integrations-engine/blob/main/marketplace/wpp_templates/serializers.py#L160

@Sandro-Meireles Sandro-Meireles changed the title Use a SlugRelatedField to retrieve the app in the TemplateMessageSerializer Use a SlugRelatedField to retrieve the app in the Template Message Serializer Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant