Patched to work with Django 1.7

I know there is a pull request for this already, but I have a more concise fix that is also backwards compatible.  

I have also patched the tests to work with Django 1.6/1.7 and included a test for my fix.  This tests that my fix accomplishes the apparent intended behavior of your original version.