[Answered ]-TypeError: String indices must be intergers Django

1👍

This is not a dictionary, but a string with as content that looks like something that is a dictionary. You can use the .literal_eval(…) function [Python-doc] of the ast module to parse this into a dictionary:

from ast import literal_eval

if y.get('comment'):
    comments = literal_eval(y.get('comment'))
    # …

But the question is why this is a string, there might be a problem more upstream where the y is "populated" with data.

Leave a comment