I am running django 1.5.5 with uwsgi. I am getting this exception in uwsgi, everything works fine with runserver:
ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e)) django.core.exceptions.ImproperlyConfigured: Error importing middleware mymodule.middleware: "cannot import name MyClass"
Here is the really strange part:
When I add this at the top of mymodule.middleware, uwsgi runs just fine:
import pdb
I don't need to enter the debugger, just import the pdb module. pdb is not referenced in the middleware. In fact I have searched the entire repository and it isn't referenced anywhere.
My first thought was some sort of circular import, but I can't find it. Any other ideas?
Update: This was indeed a circular import, in one of the imported modules. I still have no idea why importing pdb made any difference. If anyone can shed light on that, I would like to better understand what was going on.