我正在尝试将一个不可迭代的对象解压到一个 QuerySet 中。这是我的代码:
from django.shortcuts import render, get_object_or_404
from rest_framework.response import Response
...
@api_view(['GET'])
def order(request):
'''Get all the orders for a user'''
context = []
if request.GET.get('user'): #If we make a request type ?user=...
id_user = request.GET.get('user')
user = get_object_or_404(member_area, pk=id_user)
if request.GET.get('order'): #If we make specific request on an order
id_order = request.GET.get('order')
orders = commande.objects.get(id=id_order, membre_id=id_user)
else:
orders = commande.objects.filter(membre_id=id_user)
...
我想在收到请求时解包订单...?user=1&order=2。提前致谢
温温酱
相关分类