many to one일때 detail_order = DetailOrder.objects.select_related('order').get(id=request.data['id'])
one to many일땐 order = order.objects.filter(id=1).prefetch_related("detail_order")
remain_detail_order = DetailOrder.objects.filter(order__id=detail_order.order.id).count()
|