jazzband/django-redis

Import to django_redis.cache fails

iurisilvio opened this issue · 2 comments

Describe the bug
I can't import django_redis.cache.RedisCache to extend it, because the module access django.conf.settings on import time.

To Reproduce

$ python -c "import django_redis.cache"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "./lib/python3.11/site-packages/django_redis/cache.py", line 12, in <module>
    DJANGO_REDIS_SCAN_ITERSIZE = getattr(settings, "DJANGO_REDIS_SCAN_ITERSIZE", 10)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./lib/python3.11/site-packages/django/conf/__init__.py", line 87, in __getattr__
    self._setup(name)
  File "./lib/python3.11/site-packages/django/conf/__init__.py", line 67, in _setup
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting DJANGO_REDIS_SCAN_ITERSIZE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

It is ready to review.