order in orders: print(order.customer.name) SELECT * FROM ORDER INNER JOIN CUSTOMER ON ORDER.customer_id = CUSTOMER.id WHERE ORDER.created_at >= '2022-11-01';
in customers: for order in customer.order_set.all(): print(order.orderNumber) SELECT * FROM CUSTOMER WHERE CUSTOMER.address = 'Tokyo'; SELECT * FROM ORDER WHERE ORDER.customer_id IN (1, 2, 3, 4, 5);
customer in customers: print(customer.order_count) SELECT CUSTOMER.*, COUNT(ORDER.id) AS order_count FROM CUSTOMER LEFT OUTER JOIN ORDER ON CUSTOMER.id = ORDER.customer_id WHERE CUSTOMER.address = 'Tokyo' GROUP BY CUSTOMER;
category_label, entities in categories: category = Category.objects.create(label=category_label, for entity_label in entities: Entity.objects.create(label=entity_label, category=ca
roots: root = Root.objects.create(label=root_label) for category_label, entities in categories: category = Category.objects.create(label=category_label, for entity_label in entities: entity_obj_list.append(Entity(label=entity_label, cat Entity.objects.bulk_create(entity_obj_list)