the raise must happen on middleware constructor, when it is convenient to have the import at the module level we use something like:

```python
try:
    import requiredmodule
except ImportError:
    requriedmodule = None

...
class Middleware(object):
    def __init__(self, ...):
        if requiredmodule is None:
             raise NotConfigured('missing requiredmodule')

```