我是这样从TemplateResponse
返回viewset
的:
return TemplateResponse(request, 'payments/cybersource_stampduty.html', template_data)
但我遇到错误:
视图payments.views.CyberSourceResponseViewSet没有返回 HttpResponse对象。它返回None。
为什么会出现此错误?
如果有人要查看整个功能,则如下所示
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
headers = self.get_success_headers(serializer.data)
transaction = CyberSourceTransaction.objects.filter(
uuid=request.data['req_transaction_uuid']).first()
# if its a stampduty
if transaction.selected_plan_name == 'stampduty':
template_data = {
'consumer': transaction.transfer_to,
'decision': request.data['decision'],
'transaction_uuid': request.data['req_transaction_uuid'],
'reference_number': transaction.reference_number,
'amount': transaction.amount,
'currency': transaction.currency,
'wukla_url': settings.WUKLA_URL,
'paksign_url': settings.PAKSIGN_URL,
'subscription_url': settings.DOMAIN
}
logger.info("Handling Cybersource transaction response with transaction_uuid: "
+ request.data['req_transaction_uuid'], extra={'user': ''})
return TemplateResponse \
(request, 'payments/cybersource_stampduty.html', template_data)