dj-redis-panel


Namedj-redis-panel JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryA Django Admin panel for browsing and inspecting Redis keys
upload_time2025-08-12 21:30:34
maintainerYasser Toruno
docs_urlNone
authorYasser Toruno
requires_python>=3.9
licenseMIT
keywords django redis admin panel database key-value
VCS
bugtrack_url
requirements pytest pytest-django pytest-cov pytest-xdist twine build mkdocs-material
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django Redis Panel

A Django Admin panel for browsing, inspecting, and managing Redis keys. No postgres/mysql models or changes required.

![Django Redis Panel - Instance List](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/instances_list.png)

## Features

- 🔍 **Browse Redis Keys**: Search and filter Redis keys with pattern matching
- 📊 **Instance Overview**: Monitor Redis instance metrics and database statistics  
- 🔧 **Key Management**: View, edit, and delete Redis keys with support for all data types
- 🎛️ **Feature Toggles**: Granular control over operations (delete, edit, TTL updates)
- 📄 **Pagination**: Both traditional page-based and cursor-based pagination support
- 🎨 **Django Admin Integration**: Seamless integration with Django admin styling and dark mode
- 🔒 **Permission Control**: Respects Django admin permissions and staff-only access
- 🌐 **Multiple Instances**: Support for multiple Redis instances with different configurations

## Supported Redis Data Types

- **String**: View and edit string values
- **List**: Browse list items with pagination
- **Set**: View set members
- **Hash**: Display hash fields and values in a table format
- **Sorted Set**: Show sorted set members with scores

### Project Structure

```
dj-redis-panel/
├── dj_redis_panel/          # Main package
│   ├── templates/           # Django templates
│   ├── redis_utils.py       # Redis utilities
│   ├── views.py            # Django views
│   └── urls.py             # URL patterns
├── example_project/         # Example Django project
├── tests/                   # Test suite
├── images/                  # Screenshots for README
└── requirements.txt         # Development dependencies
```

## Requirements

- Python 3.9+
- Django 4.2+
- Redis 4.0+
- redis-py 4.0+



## Screenshots

### Django Admin Integration
Seamlessly integrated into your Django admin interface. A new section for dj-redis-panel
will appear in the same places where your models appear.

**NOTE:** This application does not actually introduce any model or migrations.

![Admin Home](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/admin_home.png)

### Instance Overview
Monitor your Redis instances with detailed metrics and database information.

![Instance Overview](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/instance_overview.png)

### Key Search - Page-based Pagination
Search for keys with traditional page-based navigation.

![Key Search - Page Index](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/key_search_page_index.png)

### Key Search - Cursor-based Pagination  
Efficient cursor-based pagination for large datasets.

![Key Search - Cursor](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/key_search_cursor.png)

### Key Detail - String Values
View and edit string key values with TTL management.

![Key Detail - String](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/key_detail_string.png)

### Key Detail - Other data structures
Browse keys with more complex data structures such as hashes, lists, etc. 

![Key Detail - Hash](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/key_detail_hash.png)


## Installation

### 1. Install the Package

```bash
pip install dj-redis-panel
```

### 2. Add to Django Settings

Add `dj_redis_panel` to your `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'dj_redis_panel',  # Add this line
    # ... your other apps
]
```

### 3. Configure Redis Instances

Add the Django Redis Panel configuration to your Django settings:

```python
DJ_REDIS_PANEL_SETTINGS = {
    # Global feature flags (can be overridden per instance)
    "ALLOW_KEY_DELETE": False,
    "ALLOW_KEY_EDIT": True,
    "ALLOW_TTL_UPDATE": True,
    "CURSOR_PAGINATED_SCAN": False,
    
    "INSTANCES": {
        "default": {
            "description": "Default Redis Instance",
            "host": "127.0.0.1",
            "port": 6379,
            "db": 0,
            # Optional: override global settings for this instance
            "features": {
                "ALLOW_KEY_DELETE": True,
                "CURSOR_PAGINATED_SCAN": True,
            },
        },
        "other_instance": {
            "description": "Cache Redis Instance",
            "url": "rediss://127.0.0.1:6379",
        },
    }
}
```

### 4. Include URLs

Add the Redis Panel URLs to your main `urls.py`:

```python
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('admin/redis/', include('dj_redis_panel.urls')),  # Add this line
]
```

### 5. Run Migrations and Create Superuser

```bash
python manage.py migrate
python manage.py createsuperuser  # If you don't have an admin user
```

### 6. Access the Panel

1. Start your Django development server:
   ```bash
   python manage.py runserver
   ```

2. Navigate to the Django admin at `http://127.0.0.1:8000/admin/`

3. Look for the "DJ_REDIS_PANEL" section in the admin interface

4. Click "Manage Redis keys and values" to start browsing your Redis instances

## Configuration Options

### Global Settings

| Setting | Default | Description |
|---------|---------|-------------|
| `ALLOW_KEY_DELETE` | `False` | Allow deletion of Redis keys |
| `ALLOW_KEY_EDIT` | `True` | Allow editing of key values |
| `ALLOW_TTL_UPDATE` | `True` | Allow updating key TTL (expiration) |
| `CURSOR_PAGINATED_SCAN` | `False` | Use cursor-based pagination instead of page-based |

### Instance Configuration

Each Redis instance can be configured with:

#### Connection via Host/Port:
```python
"instance_name": {
    "description": "Human-readable description",
    "host": "127.0.0.1",
    "port": 6379,
    "db": 0,                    # Optional, default: 0
    "password": "password",     # Optional
    "features": {               # Optional: override global settings
        "ALLOW_KEY_DELETE": True,
    },
}
```

#### Connection via URL:
```python
"instance_name": {
    "description": "Human-readable description", 
    "url": "redis://user:password@host:port/db",
    "features": {               # Optional: override global settings
        "CURSOR_PAGINATED_SCAN": True,
    },
}
```

### Feature Flags

Feature flags can be set globally and overridden per instance:

- **`ALLOW_KEY_DELETE`**: Controls whether the delete button is enabled
- **`ALLOW_KEY_EDIT`**: Controls whether key values can be modified
- **`ALLOW_TTL_UPDATE`**: Controls whether key expiration can be updated
- **`CURSOR_PAGINATED_SCAN`**: Chooses pagination method (cursor vs. page-based)

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

## Development Setup

If you want to contribute to this project or set it up for local development:

### Prerequisites

- Python 3.9 or higher
- Redis server running locally
- Git
- Autoconf

### 1. Clone the Repository

```bash
git clone https://github.com/yassi/dj-redis-panel.git
cd dj-redis-panel
```

### 2. Create Virtual Environment

```bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
```

### 3. Install dj-redis-panel inside of your virtualenv

A make file is included in the repository root with multiple commands for building
and maintaining this project. The best approach is to start by using one of the
package installation commands found below:
```bash
# Build and install a wheel for this project
# Also install all dev dependencies such as pytest and other utilities
make install_dev

# Build and install a wheel for this project
make install

# build and install all dev dependencies and run all tests
make test
```

### 4. Set Up Example Project

The repository includes an example Django project for development and testing:

```bash
cd example_project
python manage.py migrate
python manage.py createsuperuser
```

### 5. Populate Test Data (Optional)
An optional CLI tool for populating redis keys automatically is included in the
example django project in this code base.

```bash
python manage.py populate_redis
```

This command will populate your Redis instance with sample data for testing.

### 6. Run the Development Server

```bash
python manage.py runserver
```

Visit `http://127.0.0.1:8000/admin/` to access the Django admin with Redis Panel.

### 7. Running Tests

The project includes a comprehensive test suite. You can run them by using make or
by invoking pytest directly:

```bash
# run using make which will also install all dependencies (recommended)
make test

# run using pytest directly
pytest tests/

# Run with coverage
pytest tests/ --cov=dj_redis_panel

# Run specific test file
pytest tests/test_views.py
```

**Note**: Tests require a running Redis server on `127.0.0.1:6379`. The tests use databases 13, 14, and 15 for isolation and automatically clean up after each test.

### 8. Dockerized Redis

Test for this project (as well as any active development) require an active redis installation.
Although not required, a docker-compose file is included to allow for easy creation of local
redis instances.

```bash
# Start Redis on localhost and the usual port 6379
docker-compose up redis -d
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dj-redis-panel",
    "maintainer": "Yasser Toruno",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "django, redis, admin, panel, database, key-value",
    "author": "Yasser Toruno",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/fe/b0/418e5f86d1b6771db709cfae40a88495a4aa37ae0fa6c17dc5deec12b8c2/dj_redis_panel-0.1.2.tar.gz",
    "platform": null,
    "description": "# Django Redis Panel\n\nA Django Admin panel for browsing, inspecting, and managing Redis keys. No postgres/mysql models or changes required.\n\n![Django Redis Panel - Instance List](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/instances_list.png)\n\n## Features\n\n- \ud83d\udd0d **Browse Redis Keys**: Search and filter Redis keys with pattern matching\n- \ud83d\udcca **Instance Overview**: Monitor Redis instance metrics and database statistics  \n- \ud83d\udd27 **Key Management**: View, edit, and delete Redis keys with support for all data types\n- \ud83c\udf9b\ufe0f **Feature Toggles**: Granular control over operations (delete, edit, TTL updates)\n- \ud83d\udcc4 **Pagination**: Both traditional page-based and cursor-based pagination support\n- \ud83c\udfa8 **Django Admin Integration**: Seamless integration with Django admin styling and dark mode\n- \ud83d\udd12 **Permission Control**: Respects Django admin permissions and staff-only access\n- \ud83c\udf10 **Multiple Instances**: Support for multiple Redis instances with different configurations\n\n## Supported Redis Data Types\n\n- **String**: View and edit string values\n- **List**: Browse list items with pagination\n- **Set**: View set members\n- **Hash**: Display hash fields and values in a table format\n- **Sorted Set**: Show sorted set members with scores\n\n### Project Structure\n\n```\ndj-redis-panel/\n\u251c\u2500\u2500 dj_redis_panel/          # Main package\n\u2502   \u251c\u2500\u2500 templates/           # Django templates\n\u2502   \u251c\u2500\u2500 redis_utils.py       # Redis utilities\n\u2502   \u251c\u2500\u2500 views.py            # Django views\n\u2502   \u2514\u2500\u2500 urls.py             # URL patterns\n\u251c\u2500\u2500 example_project/         # Example Django project\n\u251c\u2500\u2500 tests/                   # Test suite\n\u251c\u2500\u2500 images/                  # Screenshots for README\n\u2514\u2500\u2500 requirements.txt         # Development dependencies\n```\n\n## Requirements\n\n- Python 3.9+\n- Django 4.2+\n- Redis 4.0+\n- redis-py 4.0+\n\n\n\n## Screenshots\n\n### Django Admin Integration\nSeamlessly integrated into your Django admin interface. A new section for dj-redis-panel\nwill appear in the same places where your models appear.\n\n**NOTE:** This application does not actually introduce any model or migrations.\n\n![Admin Home](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/admin_home.png)\n\n### Instance Overview\nMonitor your Redis instances with detailed metrics and database information.\n\n![Instance Overview](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/instance_overview.png)\n\n### Key Search - Page-based Pagination\nSearch for keys with traditional page-based navigation.\n\n![Key Search - Page Index](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/key_search_page_index.png)\n\n### Key Search - Cursor-based Pagination  \nEfficient cursor-based pagination for large datasets.\n\n![Key Search - Cursor](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/key_search_cursor.png)\n\n### Key Detail - String Values\nView and edit string key values with TTL management.\n\n![Key Detail - String](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/key_detail_string.png)\n\n### Key Detail - Other data structures\nBrowse keys with more complex data structures such as hashes, lists, etc. \n\n![Key Detail - Hash](https://raw.githubusercontent.com/yassi/dj-redis-panel/main/images/key_detail_hash.png)\n\n\n## Installation\n\n### 1. Install the Package\n\n```bash\npip install dj-redis-panel\n```\n\n### 2. Add to Django Settings\n\nAdd `dj_redis_panel` to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'dj_redis_panel',  # Add this line\n    # ... your other apps\n]\n```\n\n### 3. Configure Redis Instances\n\nAdd the Django Redis Panel configuration to your Django settings:\n\n```python\nDJ_REDIS_PANEL_SETTINGS = {\n    # Global feature flags (can be overridden per instance)\n    \"ALLOW_KEY_DELETE\": False,\n    \"ALLOW_KEY_EDIT\": True,\n    \"ALLOW_TTL_UPDATE\": True,\n    \"CURSOR_PAGINATED_SCAN\": False,\n    \n    \"INSTANCES\": {\n        \"default\": {\n            \"description\": \"Default Redis Instance\",\n            \"host\": \"127.0.0.1\",\n            \"port\": 6379,\n            \"db\": 0,\n            # Optional: override global settings for this instance\n            \"features\": {\n                \"ALLOW_KEY_DELETE\": True,\n                \"CURSOR_PAGINATED_SCAN\": True,\n            },\n        },\n        \"other_instance\": {\n            \"description\": \"Cache Redis Instance\",\n            \"url\": \"rediss://127.0.0.1:6379\",\n        },\n    }\n}\n```\n\n### 4. Include URLs\n\nAdd the Redis Panel URLs to your main `urls.py`:\n\n```python\nfrom django.contrib import admin\nfrom django.urls import path, include\n\nurlpatterns = [\n    path('admin/', admin.site.urls),\n    path('admin/redis/', include('dj_redis_panel.urls')),  # Add this line\n]\n```\n\n### 5. Run Migrations and Create Superuser\n\n```bash\npython manage.py migrate\npython manage.py createsuperuser  # If you don't have an admin user\n```\n\n### 6. Access the Panel\n\n1. Start your Django development server:\n   ```bash\n   python manage.py runserver\n   ```\n\n2. Navigate to the Django admin at `http://127.0.0.1:8000/admin/`\n\n3. Look for the \"DJ_REDIS_PANEL\" section in the admin interface\n\n4. Click \"Manage Redis keys and values\" to start browsing your Redis instances\n\n## Configuration Options\n\n### Global Settings\n\n| Setting | Default | Description |\n|---------|---------|-------------|\n| `ALLOW_KEY_DELETE` | `False` | Allow deletion of Redis keys |\n| `ALLOW_KEY_EDIT` | `True` | Allow editing of key values |\n| `ALLOW_TTL_UPDATE` | `True` | Allow updating key TTL (expiration) |\n| `CURSOR_PAGINATED_SCAN` | `False` | Use cursor-based pagination instead of page-based |\n\n### Instance Configuration\n\nEach Redis instance can be configured with:\n\n#### Connection via Host/Port:\n```python\n\"instance_name\": {\n    \"description\": \"Human-readable description\",\n    \"host\": \"127.0.0.1\",\n    \"port\": 6379,\n    \"db\": 0,                    # Optional, default: 0\n    \"password\": \"password\",     # Optional\n    \"features\": {               # Optional: override global settings\n        \"ALLOW_KEY_DELETE\": True,\n    },\n}\n```\n\n#### Connection via URL:\n```python\n\"instance_name\": {\n    \"description\": \"Human-readable description\", \n    \"url\": \"redis://user:password@host:port/db\",\n    \"features\": {               # Optional: override global settings\n        \"CURSOR_PAGINATED_SCAN\": True,\n    },\n}\n```\n\n### Feature Flags\n\nFeature flags can be set globally and overridden per instance:\n\n- **`ALLOW_KEY_DELETE`**: Controls whether the delete button is enabled\n- **`ALLOW_KEY_EDIT`**: Controls whether key values can be modified\n- **`ALLOW_TTL_UPDATE`**: Controls whether key expiration can be updated\n- **`CURSOR_PAGINATED_SCAN`**: Chooses pagination method (cursor vs. page-based)\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Development Setup\n\nIf you want to contribute to this project or set it up for local development:\n\n### Prerequisites\n\n- Python 3.9 or higher\n- Redis server running locally\n- Git\n- Autoconf\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/yassi/dj-redis-panel.git\ncd dj-redis-panel\n```\n\n### 2. Create Virtual Environment\n\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n### 3. Install dj-redis-panel inside of your virtualenv\n\nA make file is included in the repository root with multiple commands for building\nand maintaining this project. The best approach is to start by using one of the\npackage installation commands found below:\n```bash\n# Build and install a wheel for this project\n# Also install all dev dependencies such as pytest and other utilities\nmake install_dev\n\n# Build and install a wheel for this project\nmake install\n\n# build and install all dev dependencies and run all tests\nmake test\n```\n\n### 4. Set Up Example Project\n\nThe repository includes an example Django project for development and testing:\n\n```bash\ncd example_project\npython manage.py migrate\npython manage.py createsuperuser\n```\n\n### 5. Populate Test Data (Optional)\nAn optional CLI tool for populating redis keys automatically is included in the\nexample django project in this code base.\n\n```bash\npython manage.py populate_redis\n```\n\nThis command will populate your Redis instance with sample data for testing.\n\n### 6. Run the Development Server\n\n```bash\npython manage.py runserver\n```\n\nVisit `http://127.0.0.1:8000/admin/` to access the Django admin with Redis Panel.\n\n### 7. Running Tests\n\nThe project includes a comprehensive test suite. You can run them by using make or\nby invoking pytest directly:\n\n```bash\n# run using make which will also install all dependencies (recommended)\nmake test\n\n# run using pytest directly\npytest tests/\n\n# Run with coverage\npytest tests/ --cov=dj_redis_panel\n\n# Run specific test file\npytest tests/test_views.py\n```\n\n**Note**: Tests require a running Redis server on `127.0.0.1:6379`. The tests use databases 13, 14, and 15 for isolation and automatically clean up after each test.\n\n### 8. Dockerized Redis\n\nTest for this project (as well as any active development) require an active redis installation.\nAlthough not required, a docker-compose file is included to allow for easy creation of local\nredis instances.\n\n```bash\n# Start Redis on localhost and the usual port 6379\ndocker-compose up redis -d\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Django Admin panel for browsing and inspecting Redis keys",
    "version": "0.1.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/yassi/dj-redis-panel/issues",
        "Documentation": "https://yassi.github.io/dj-redis-panel/",
        "Homepage": "https://yassi.github.io/dj-redis-panel/",
        "Repository": "https://github.com/yassi/dj-redis-panel"
    },
    "split_keywords": [
        "django",
        " redis",
        " admin",
        " panel",
        " database",
        " key-value"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8797a60b22782118d3e113ae1b92b3a39732f382ec3d06374c73ef749772d37d",
                "md5": "de40afe0dcf151b3ea2607aa8add075f",
                "sha256": "75230d37f82aae025762cf244802b6bd00c8bcc9502a80605f7d6716b8de731e"
            },
            "downloads": -1,
            "filename": "dj_redis_panel-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "de40afe0dcf151b3ea2607aa8add075f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 23880,
            "upload_time": "2025-08-12T21:30:33",
            "upload_time_iso_8601": "2025-08-12T21:30:33.561947Z",
            "url": "https://files.pythonhosted.org/packages/87/97/a60b22782118d3e113ae1b92b3a39732f382ec3d06374c73ef749772d37d/dj_redis_panel-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "feb0418e5f86d1b6771db709cfae40a88495a4aa37ae0fa6c17dc5deec12b8c2",
                "md5": "2718a343da601406dbc90900b53f11ea",
                "sha256": "aa36cc5dd78228673f74591ae0d1656074c31afb95939e192719c18c3c821557"
            },
            "downloads": -1,
            "filename": "dj_redis_panel-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2718a343da601406dbc90900b53f11ea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 31063,
            "upload_time": "2025-08-12T21:30:34",
            "upload_time_iso_8601": "2025-08-12T21:30:34.724996Z",
            "url": "https://files.pythonhosted.org/packages/fe/b0/418e5f86d1b6771db709cfae40a88495a4aa37ae0fa6c17dc5deec12b8c2/dj_redis_panel-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-12 21:30:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yassi",
    "github_project": "dj-redis-panel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pytest",
            "specs": [
                [
                    ">=",
                    "7.0.0"
                ]
            ]
        },
        {
            "name": "pytest-django",
            "specs": [
                [
                    ">=",
                    "4.5.0"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    ">=",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "pytest-xdist",
            "specs": [
                [
                    ">=",
                    "3.2.0"
                ]
            ]
        },
        {
            "name": "twine",
            "specs": [
                [
                    "==",
                    "6.1.0"
                ]
            ]
        },
        {
            "name": "build",
            "specs": [
                [
                    "==",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "mkdocs-material",
            "specs": [
                [
                    "==",
                    "9.1.12"
                ]
            ]
        }
    ],
    "lcname": "dj-redis-panel"
}
        
Elapsed time: 0.53499s