Ah, I see, in which case contentgroup_set.get() will be empty, so .group_id will fail. Yes. I was thinking that filter() would return me an empty set if there wasn't anything matching, and forgetting that the chain inside the filter could throw an exception. Nice catch.