setting.py

import redis
REDIS_DB = redis.Redis(host='127.0.0.1',port=6379,db=1)    
                                                    #db = 默认为1

还可以这样的配置

# redis 的配置文件
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "CONNECTION_POOL_KWARGS": {"max_connections": 100}
            # "PASSWORD": "密码",
        }
    }
}

两种方法各有各的用途,懵逼的很