Fixes for Django 1.6

Since Django 1.6 changed WhereNode a bit, I've added changes to make 1.6 work while preserving backwards compatibility.  This should and needs to be reviewed.  There might be a better way to handle this.