Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

fetching data from multiple tables using related name in django

Order.objects.select_related('account_customer').all() 
    .values('customer_id', 'other_field_1', ...) 
    .annotate(total_sales=Sum('total_price')) 
    .filter(created_at__year=today.year, created_at__month=today.month)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #fetching #data #multiple #tables #related #django
ADD COMMENT
Topic
Name
9+9 =