And, actually, Django ORM querysets are lazy, so it wouldn't hurt to make the full set of queries at the top of the function (instead of putting `None` for each), and then you don't need these `if` statements in each of the cases. See https://docs.djangoproject.com/en/dev/topics/db/queries/#querysets-are-lazy