Change the MIDDLEWARE_CLASSES to not use sets since this does not preserve order which is necessary for the MIDDLEWARE_CLASSES.