【发布时间】:2017-07-02 08:15:43
【问题描述】:
我想将数据保存在我的数据库中,但我的代码中有 TypeError。 实际错误是:
TypeError: int() 参数必须是字符串、类似字节的对象或数字,而不是 'QueryDict'
所以请帮我解决这个问题。 以下是我在 Views.py 上的代码:
card = Cards_detail(request.POST)
card.user_id = int((request.user.id))
card.card_no = int(request.POST['card-number'])
card.expiray_month = request.POST['expiry-month']
card.expiray_year = request.POST['expiry-year']
card.card_type = 'Visa' #temp value change this value as per api
#card.bank_id = 1 # temp value change this value as per api
card.save() # Saving Card Details
【问题讨论】:
-
实际错误是:-TypeError: int() 参数必须是字符串、字节类对象或数字,而不是'QueryDict'
-
请尝试打印 request.POST['card-number'].
标签: python django django-views