local_settings is imported by settings, so it cannot see the variables set in settings.  Need to repeat MIDDLEWARE_CLASSES here.
Decomplicated printing of debug messages.