예제 #1
0
 def get_comments(self, obj):
     content_type = obj.get_content_type
     obj_id = obj.id
     c_qs = Comment.objects.filter_by_instance(obj)
     return CommentSerializer(c_qs, many=True).data
예제 #2
0
 def get_comments(self, obj):
     c_qs = Comment.objects.filter_by_instance(obj)
     comments = CommentSerializer(c_qs, many=True).data
     return comments
예제 #3
0
 def get_comments(self, obj):
     c_qs = Comment.objects.filter_by_instance(
         obj)  #comment_qs; filter_by_instance() also defined by ourselves
     comments = CommentSerializer(c_qs, many=True).data
     return comments
예제 #4
0
파일: views.py 프로젝트: mentix02/revolve
 def post(self, request, pk: int):
     protest = get_object_or_404(Protest, pk=pk)
     comment = Comment.objects.create(protest=protest, user=request.user)
     return Response(CommentSerializer(comment).data,
                     status=status.HTTP_201_CREATED)
예제 #5
0
 def get_comment(self, obj):
     # content_type = obj.get_content_type
     # object_id = obj.id
     c_qs = Comment.objects.filter_by_instance(obj)
     comments = CommentSerializer(c_qs, many=True).data
     return comments
예제 #6
0
 def get_comments(self, obj):
     queryset = Comment.objects.filter(parent=Status.objects.get(id=obj.id))
     comments = CommentSerializer(queryset, many=True).data
     return comments
예제 #7
0
 def to_representation(self, instance):
     ret = super(PublicationSerializer, self).to_representation(instance)
     comment_instance = Comments.objects.filter(commented_on=instance.pk)
     ret["comments"] = CommentSerializer(instance=comment_instance,
                                         many=True).data
     return ret
예제 #8
0
def test_serialize_comment(comment):
    serializer = CommentSerializer(comment)
    serializer.data  # No errors
예제 #9
0
 def get_comments(self, obj):
     c_qs = Comment.objects.filter(post=obj.id, parent_comment__isnull=True)
     comments = CommentSerializer(c_qs, many=True).data
     return comments
예제 #10
0
 def get_comments(self, obj):
     return CommentSerializer(obj.comment_set.all(), many=True).data
예제 #11
0
from rest_framework.serializers import (HyperlinkedIdentityField,