Django 1.11 TypeError context must be a dict rather than Context

后端 未结 3 1335
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 15:33

Just received the Sentry error TypeError context must be a dict rather than Context. on one of my forms. I know it has something to do with Django 1.11, but I

3条回答
  •  情书的邮戳
    2020-12-01 16:03

    For django 1.11 and after, context must be dict.

    You can use:

    context_dict = get_context_dict(context)
    return t.render(context_dict)
    

    or

    context_dict = context.flatten()
    return t.render(context_dict)
    

提交回复
热议问题