无法将bool设置为True

时间:2015-10-12 16:46:10

标签: python django deployment pythonanywhere

我刚刚将我的代码部署到实时环境(PythonAnywhere)并在我尝试更改模型字段时遇到异常:

paid = models.BooleanField(default=False)

我尝试

时得到'bool' object is not subscriptable
payment = paypalrestsdk.Payment.find(payment_id)
response = payment.execute({"payer_id": payer_id})
trans = Transaction.objects.get(paypal_id=payment_id)
if response:
  trans.paid = True # <--- Here
  trans.save()

追溯

File "/home/my/proj/myenv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/my/proj/api/views/paypal.py" in success
  15.         paypal.finish_payment(payment_id, payer_id)
File "/home/my/proj/api/payment_processors/paypal_processor.py" in finish_payment
  54.             trans.paid = True

Exception Type: TypeError at /api/paypal/success
Exception Value: 'bool' object is not subscriptable

0 个答案:

没有答案