Connect local django application to redis container

81 Views Asked by At

I have a django project in local machine + In the docker i have redis container and that is up. when i use docker ps i get this result:

CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS          PORTS                    NAMES
ff39ad874428   redis      "docker-entrypoint.s…"   52 minutes ago   Up 50 minutes   0.0.0.0:6379->6379/tcp   redis2

and this is my cache config in django setting.py:

CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': 'redis://localhost:6379',  # Adjust the host and port if needed
        # 'OPTIONS': {
        #     'CLIENT_CLASS': 'django_redis.client.DefaultClient',
        # }
    }
}

So when i cache in my view, Dosnt save any data. First, How can i check the connection from django to redis container? Second, How can i add new key from django into redis container? Thanks.

0

There are 0 best solutions below