Code Room
Code reviewMediumcr-g196
Subject N plus oneLevel Mid–Senior~25 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Python (Django ORM) view that serializes orders with their line items.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewpython
def order_report(request):    orders = Order.objects.filter(        created__gte=last_month()    ).order_by("-created")    rows = []    for order in orders:        rows.append({            "id": order.id,            "customer": order.customer.name,            "total": sum(item.qty * item.unit_price                         for item in order.items.all()),            "warehouse": order.shipment.warehouse.code,        })    return JsonResponse({"rows": rows})
Run or narrate your approach, then ask the coach.