Django 1.7 support for app discovery

* Refactored @Xaroth’s patch from #1015 into a separate utils
  module 
* PEP-8 cleanup