Update middleware.py
Merge pull request #1 from WCF/master

Fix for Django deprecation