Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
serialize post
from django_blog.apps.blog.models import Post
from django_blog.apps.blog.rest_api.serializers.post import PostSerializer
post = Post.objects.create(title='First post', text='This is a first post')
print(PostSerializer(post).data)
# {'pk': '4670511f-4a03-455e-a160-18c396fa743d', 'title': 'First post', 'text': 'This is a first post', 'tags': [], 'author': None, 'image': None}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.