[Django]-Wrap python decorator with another decorator

5👍

Just assign it to a value:

use_real_cache = override_settings(
    CACHES={
        **settings.CACHES,
        'default': generate_cache('default', dummy=False),
        'throttling': generate_cache('throttling', dummy=False),
    }
)

# …

@use_real_cache
def test_something():
    # …
    pass

This is essentially what happens in the first code sample of the question, except that you do not assign it to an (explicit) variable.

Leave a comment