[Fixed]-Object is not subscriptable using django and python

29👍

TypeError: 'StudentSubjectGrade' object is not subscriptable

this means that student is not a dictionary, you cannot use student['key'] to get what you want.

you should use student.sth instead.

8👍

Use getattr(student, 'key') instead; with ‘key’ e.g ‘id’

Leave a comment