相关疑难解决方法(0)

Django 1.11 TypeError上下文必须是dict而不是Context

TypeError context must be a dict rather than Context.在我的一个表单上收到了Sentry错误.我知道它与Django 1.11有关,但我不知道要修改什么来修复它.

违规线

message = get_template('email_forms/direct_donation_form_email.html').render(Context(ctx))

整个视图

def donation_application(request):
    if request.method == 'POST':
        form = DirectDonationForm(data=request.POST)
        if form.is_valid():
            stripe.api_key = settings.STRIPE_SECRET_KEY
            name = request.POST.get('name', '')
            address = request.POST.get('address', '')
            city = request.POST.get('city', '')
            state = request.POST.get('state', '')
            zip = request.POST.get('zip', '')
            phone_number = request.POST.get('phone_number', '')
            support = request.POST.get('support', '')
            agree = request.POST.get('agree', '')
            email_address = request.POST.get('email_address', '')
            number = request.POST.get('number', '')
            cvc = request.POST.get('cvc', '')
            exp = request.POST.get('exp', '')
            # …
Run Code Online (Sandbox Code Playgroud)

python django django-views

43
推荐指数
2
解决办法
4万
查看次数

标签 统计

django ×1

django-views ×1

python ×1