Patched to work with Django 1.7 and added a test for the fix