Closed SHxKM closed 4 years ago
Try config('REDIS_URL', default='127.0.0.1, 6379', cast=Csv(post_process=tuple))
The result should be ('127.0.0.1', '6379')
.
The default
parameter should be a string to be casted.
If you need the port number to be an integer, I would recommend something like:
# casts.py
def redis_url(s):
parts = s.split(':')
return tuple(parts[0], int(parts[1])
# settings.py
from casts import redis_url
REDIS _URL= config('REDIS_URL', default='127.0.0.1:6379', cast=redis_url)
REDIS_HOSTS
in Django expects a list of tuples.When I try to do this:
I can't start my server, and this error is shown: