Package: django-redis-admin
IntroductionWithdjango-redis-adminyou can view (and in the future, edit) your Redis
databases. It supports simple servers, master slave setups and sentinel setups.The admin works by creating aRedisQuerysetwhich fakes Django models and
querysets so theModelAdminthinks it’s using a regular database backed model.Since Redis only supports basic types the library allows for optionalbase64encoding/decoding andjsonencoding/decoding.While I would not recommend using it as a regular queryset to access Redis. In
addition to querying data it does some extra queries which you usually don’t
need (such as fetching idle data) and it does some automatic conversion steps.RequirementsPython3.6and aboveDjango (tested with 2.1, probably works with any version that supports
Python 3)Python-redis (pip install redis)Installationdjango-redis-admincan be installed via pip.pipinstalldjango-redis-adminThen just addredis_adminto yourINSTALLED_APPS.Optionally, configure your servers if you have multiple and/or non-standard
(i.e. non-localhost) redis servers.Below are several example configurations. The default settings can always be
found inredis_admin/settings.pyYou can run the demo project using the following commands:cdtest_redis_adminpythonmanage.pyrunserverThe default username/password isadmin/admin:http://localhost:8080/admin/Basic configuration# https://redis-py.readthedocs.io/en/latest/index.html#redis.RedisREDIS_SERVERS=dict(localhost=dict(),)Explicit configuration# https://redis-py.readthedocs.io/en/latest/index.html#redis.RedisREDIS_SERVERS=dict(redis_server_a=dict(host='127.0.0.1',port=6379,db=0),)Master slave configuration# https://redis-py.readthedocs.io/en/latest/index.html#redis.RedisREDIS_SERVERS=dict(redis_server_a=dict(master=dict(host='master_hostname',port=6379,db=0),slave=dict(host='slave_hostname',port=6379,db=0),))Sentinel Configuration# The `REDIS_SENTINELS` setting should be a list containing host/port# combinations. As documented here:# https://github.com/andymccurdy/redis-py/blob/master/README.rst#sentinel-supportREDIS_SENTINELS=[('server_a',26379),('server_b',26379)]# The `REDIS_SENTINEL_OPTIONS` are the extra arguments to# `redis.sentinel.Sentinel`:# https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/sentinel.py#L128-L155REDIS_SENTINEL_OPTIONS=dict(socket_timeout=0.1)# The `service_name` is used to find the server within the Sentinel# configuration. The dictionary key will be used as the name in the admin# https://redis-py.readthedocs.io/en/latest/index.html#redis.RedisREDIS_SERVERS=dict(name_in_admin=dict(service_name='name_in_sentinel'),other_server=dict(service_name='other_server'),)Base64 and/or JSON decodingAs a convenient option all values can optionally bebase64and/orjsonencoded. To configure this a regular expression can be specified which will be
matched against the keys.# For all keysREDIS_JSON_KEY_RE='.*'REDIS_BASE64_KEY_RE='.*'# Keys starting with a pattern:REDIS_BASE64_KEY_RE='^some_prefix.*'# Keys ending with a pattern:REDIS_JSON_KEY_RE='.*some_suffix$'And if a specificjsondecoder is needed, thejsonmodule can be specified.
The module needs to be importable and have adumpsandloadsmethod. By
default it simply imports thejsonmodule:REDIS_JSON_MODULE='json'Representation croppingWithin the Django Admin list view the values are cropped by default to prevent really long lines. This size can be adjusted through:REDIS_REPR_CROP_SIZE=150TODOAllow saving valuesAllow deleting valuesSupport Redis BitmapsSupport Redis HyperLogLogs