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

Customize serializer #7

Open
ccapeng opened this issue Dec 1, 2020 · 0 comments
Open

Customize serializer #7

ccapeng opened this issue Dec 1, 2020 · 0 comments

Comments

@ccapeng
Copy link

ccapeng commented Dec 1, 2020

I am looking at how to customize serializer

How do I have data from two join tables?

In the restframework, I can do like :

class BookSerializer(serializers.ModelSerializer):
    category_name = serializers.CharField(source='category.name', read_only=True)
    publisher_name = serializers.CharField(source='publisher.name', read_only=True)
    author_last_name = serializers.CharField(source='author.last_name', read_only=True)
    author_first_name = serializers.CharField(source='author.first_name', read_only=True)

    class Meta:
        model = Book
        fields = (
            'id', 
            'title', 
            'category', 
            'category_name', 
            'publisher', 
            'publisher_name', 
            'author', 
            'author_last_name', 
            'author_first_name'
        )

How should I do in grpc?

I almost got my django-grpc + react CRUD working.

https://github.com/ccapeng/bookstore_grpc
https://github.com/ccapeng/bookstore-redux-grpc

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