Created
September 8, 2019 22:47
-
-
Save olegkovalov/3d8349fc890bc57411779fea352918cb to your computer and use it in GitHub Desktop.
serialize post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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