我在理解此错误消息时遇到问题。
我已经在自己的观点中写过了这行代码
qs = Stockdata.objects.filter(User=self.request.user, Company=company_details.pk, Date__gte=selectdatefield_details.Start_Date, Date__lte=selectdatefield_details.End_Date)
total = qs.annotate(Sum('salestock__Quantity'))['the_sum']
total2 = qs.annotate(Sum('purchasestock__Quantity_p'))['the_sum']
tqty = total2 - total
context['Totalquantity'] = tqty
context['Totalquantitysales'] = total
context['Totalquantitypurchase'] = total2
有人对我在代码中做错的事情有任何想法吗?
谢谢
TraceBack:
Traceback:
File "C:\Users\HP\myEnv\lib\site-packages\django\core\handlers\exception.py" in inner
35. response = get_response(request)
File "C:\Users\HP\myEnv\lib\site-packages\django\core\handlers\base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "C:\Users\HP\myEnv\lib\site-packages\django\core\handlers\base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\HP\myEnv\lib\site-packages\django\views\generic\base.py" in view
69. return self.dispatch(request, *args, **kwargs)
File "C:\Users\HP\myEnv\lib\site-packages\django\contrib\auth\mixins.py" in dispatch
52. return super().dispatch(request, *args, **kwargs)
File "C:\Users\HP\myEnv\lib\site-packages\django\views\generic\base.py" in dispatch
89. return handler(request, *args, **kwargs)
File "C:\Users\HP\myEnv\lib\site-packages\django\views\generic\list.py" in get
157. context = self.get_context_data()
File "C:\Users\HP\My Documents\github\erpcloud\erpcloud\stockkeeping\views.py" in get_context_data
446. total = qs.annotate(Sum('salestock__Quantity'))['the_sum']
File "C:\Users\HP\myEnv\lib\site-packages\django\db\models\query.py" in __getitem__
282. raise TypeError
Exception Type: TypeError at /stockkeeping/company/31/date/13/
Exception Value: