Implement workaround for django bug #15152 for badly encoded URLs

Hopefully this will stop the system spamming us..