Sync with upstream.

Made sure tests are passing across all major Django versions from 1.3
to 1.6.