Creating object branched from object and setting the root object id to the parent_object field

With this function

 def post(request, note_id, comment_id=None):
    """Create a comment under a post/idea."""["owner"] = request.user["id"]["note_id"] = note_id
    if comment_id:
            parent_comment = Comment.objects.get(id=comment_id)
  ["parent_comment"] = parent_comment
        except Comment.DoesNotExist:
  ["parent_comment"] = None
    else:["parent_comment"] = None
    serializer = CommentSerializer(
    if serializer.is_valid(raise_exception=True):
    return Response( 

serializer for the comment model

class CommentSerializer(serializers.ModelSerializer):

class Meta:
    model = Comment
    fields = "__all__"

and my url path

path("<uuid:note_id>/comments/<uuid:comment_id>/replies/", views.CommentsGetOrCreateView.as_view(), name="CommentRepliesGetOrCreateView")

I'm trying to create Comment off of a Comment that is created off of a Note. Currently i can create a Note and create a Comment off of it and can retrieve comments under a comment but cant POST with the given url below as i need to. I currently get error on postman as ["parent_comment" : "Must be a valid UUID"]

I have tried reorganizing my post method and tried changing the serializer so the parent_comment can be null. Ive also tried adding .id at the end of "["parent_comment"] ="

Back to Top