update middleware to use current django mechanism