[Answer]-Invalid json in Django-mptt model

1πŸ‘

βœ…

the solution is join comments by comma β€˜,’

def _render_node(self, context, node):
        # print "node-> ",node
        bits = []
        context.push()
        #print "context->", context
        for child in node.get_children():
            bits.append(self._render_node(context, child))
        context['node'] = node
        context['children'] = mark_safe(','.join(bits))   **#join by ,**
        rendered = self.template_nodes.render(context)
        context.pop()
        return rendered

    def render(self, context):
        queryset = self.queryset_var.resolve(context)
        comment_order = self.order.resolve(context)
        roots = cache_tree_children(queryset, comment_order)
        # print "roots-> ", roots
        bits = [self._render_node(context, node) for node in roots]
        # print bits
        return ','.join(bits)   **#join by ,**
πŸ‘€Inforian

Leave a comment