Skip to content

Instantly share code, notes, and snippets.

@olegkovalov
Created September 8, 2019 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olegkovalov/3d8349fc890bc57411779fea352918cb to your computer and use it in GitHub Desktop.
Save olegkovalov/3d8349fc890bc57411779fea352918cb to your computer and use it in GitHub Desktop.
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