﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27841	ORM 'join on' with extra restrictions	Brett Huff	nobody	"My use case is a budget app.  I have the following:

class Category

class Transaction
date: date
amount: decimal
category: manytomany(Category, through=Split)

I need to get all categories with the amount spent in a month, even if no money was spent in that category for the month.  My SQL solution is to ""LEFT OUTER JOIN transaction ON (split.transaction_id = transaction.id and date between <earliest> and <latest>)"", then I can get the sum of ""transaction__amount"".  Every Django ORM solution I've tried will return only the categories with at least one transaction during the month, so I'm missing a bunch of categories when the month starts.

I'm going to use extra or raw until I can figure out a better way to get the results I want.  I was told (by https://docs.djangoproject.com/en/1.10/ref/models/querysets/) to open a ticket to tell you about my legitimate usage."	New feature	closed	Database layer (models, ORM)	1.10	Normal	duplicate	QuerySet.extra		Unreviewed	0	0	0	0	0	0
