dj-redis-panel 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dj_redis_panel-0.1.0/LICENSE +21 -0
- dj_redis_panel-0.1.0/MANIFEST.in +2 -0
- dj_redis_panel-0.1.0/PKG-INFO +372 -0
- dj_redis_panel-0.1.0/README.md +332 -0
- dj_redis_panel-0.1.0/dj_redis_panel/__init__.py +0 -0
- dj_redis_panel-0.1.0/dj_redis_panel/admin.py +27 -0
- dj_redis_panel-0.1.0/dj_redis_panel/apps.py +6 -0
- dj_redis_panel-0.1.0/dj_redis_panel/models.py +14 -0
- dj_redis_panel-0.1.0/dj_redis_panel/redis_utils.py +463 -0
- dj_redis_panel-0.1.0/dj_redis_panel/templates/admin/dj_redis_panel/base.html +24 -0
- dj_redis_panel-0.1.0/dj_redis_panel/templates/admin/dj_redis_panel/index.html +145 -0
- dj_redis_panel-0.1.0/dj_redis_panel/templates/admin/dj_redis_panel/instance_overview.html +119 -0
- dj_redis_panel-0.1.0/dj_redis_panel/templates/admin/dj_redis_panel/key_detail.html +296 -0
- dj_redis_panel-0.1.0/dj_redis_panel/templates/admin/dj_redis_panel/key_search.html +205 -0
- dj_redis_panel-0.1.0/dj_redis_panel/templates/admin/dj_redis_panel/styles.css +402 -0
- dj_redis_panel-0.1.0/dj_redis_panel/urls.py +19 -0
- dj_redis_panel-0.1.0/dj_redis_panel/views.py +316 -0
- dj_redis_panel-0.1.0/dj_redis_panel.egg-info/PKG-INFO +372 -0
- dj_redis_panel-0.1.0/dj_redis_panel.egg-info/SOURCES.txt +27 -0
- dj_redis_panel-0.1.0/dj_redis_panel.egg-info/dependency_links.txt +1 -0
- dj_redis_panel-0.1.0/dj_redis_panel.egg-info/requires.txt +12 -0
- dj_redis_panel-0.1.0/dj_redis_panel.egg-info/top_level.txt +3 -0
- dj_redis_panel-0.1.0/pyproject.toml +97 -0
- dj_redis_panel-0.1.0/setup.cfg +4 -0
- dj_redis_panel-0.1.0/setup.py +3 -0
- dj_redis_panel-0.1.0/tests/test_index.py +180 -0
- dj_redis_panel-0.1.0/tests/test_instance_overview.py +367 -0
- dj_redis_panel-0.1.0/tests/test_key_detail.py +270 -0
- dj_redis_panel-0.1.0/tests/test_key_search.py +249 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Yasser Toruno
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dj-redis-panel
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Django Admin panel for browsing and inspecting Redis keys
|
|
5
|
+
Author: Yasser Toruno
|
|
6
|
+
Maintainer: Yasser Toruno
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/yassi/dj-redis-panel
|
|
9
|
+
Project-URL: Documentation, https://github.com/yassi/dj-redis-panel
|
|
10
|
+
Project-URL: Repository, https://github.com/yassi/dj-redis-panel
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/yassi/dj-redis-panel/issues
|
|
12
|
+
Keywords: django,redis,admin,panel,database,key-value
|
|
13
|
+
Classifier: Framework :: Django
|
|
14
|
+
Classifier: Framework :: Django :: 4.2
|
|
15
|
+
Classifier: Framework :: Django :: 5.0
|
|
16
|
+
Classifier: Framework :: Django :: 5.1
|
|
17
|
+
Classifier: Framework :: Django :: 5.2
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Operating System :: OS Independent
|
|
24
|
+
Classifier: Intended Audience :: Developers
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: Django>=4.2
|
|
30
|
+
Requires-Dist: redis>=4.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-django>=4.5.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-xdist>=3.2.0; extra == "dev"
|
|
36
|
+
Provides-Extra: build
|
|
37
|
+
Requires-Dist: build>=1.0.0; extra == "build"
|
|
38
|
+
Requires-Dist: twine>=4.0.0; extra == "build"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# Django Redis Panel
|
|
42
|
+
|
|
43
|
+
A Django Admin panel for browsing, inspecting, and managing Redis keys. No postgres/mysql models or changes required.
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- 🔍 **Browse Redis Keys**: Search and filter Redis keys with pattern matching
|
|
50
|
+
- 📊 **Instance Overview**: Monitor Redis instance metrics and database statistics
|
|
51
|
+
- 🔧 **Key Management**: View, edit, and delete Redis keys with support for all data types
|
|
52
|
+
- 🎛️ **Feature Toggles**: Granular control over operations (delete, edit, TTL updates)
|
|
53
|
+
- 📄 **Pagination**: Both traditional page-based and cursor-based pagination support
|
|
54
|
+
- 🎨 **Django Admin Integration**: Seamless integration with Django admin styling and dark mode
|
|
55
|
+
- 🔒 **Permission Control**: Respects Django admin permissions and staff-only access
|
|
56
|
+
- 🌐 **Multiple Instances**: Support for multiple Redis instances with different configurations
|
|
57
|
+
|
|
58
|
+
## Supported Redis Data Types
|
|
59
|
+
|
|
60
|
+
- **String**: View and edit string values
|
|
61
|
+
- **List**: Browse list items with pagination
|
|
62
|
+
- **Set**: View set members
|
|
63
|
+
- **Hash**: Display hash fields and values in a table format
|
|
64
|
+
- **Sorted Set**: Show sorted set members with scores
|
|
65
|
+
|
|
66
|
+
### Project Structure
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
dj-redis-panel/
|
|
70
|
+
├── dj_redis_panel/ # Main package
|
|
71
|
+
│ ├── templates/ # Django templates
|
|
72
|
+
│ ├── redis_utils.py # Redis utilities
|
|
73
|
+
│ ├── views.py # Django views
|
|
74
|
+
│ └── urls.py # URL patterns
|
|
75
|
+
├── example_project/ # Example Django project
|
|
76
|
+
├── tests/ # Test suite
|
|
77
|
+
├── images/ # Screenshots for README
|
|
78
|
+
└── requirements.txt # Development dependencies
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Requirements
|
|
82
|
+
|
|
83
|
+
- Python 3.9+
|
|
84
|
+
- Django 4.2+
|
|
85
|
+
- Redis 4.0+
|
|
86
|
+
- redis-py 4.0+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
## Screenshots
|
|
91
|
+
|
|
92
|
+
### Django Admin Integration
|
|
93
|
+
Seamlessly integrated into your Django admin interface. A new section for dj-redis-panel
|
|
94
|
+
will appear in the same places where your models appear.
|
|
95
|
+
|
|
96
|
+
**NOTE:** This application does not actually introduce any model or migrations.
|
|
97
|
+
|
|
98
|
+

|
|
99
|
+
|
|
100
|
+
### Instance Overview
|
|
101
|
+
Monitor your Redis instances with detailed metrics and database information.
|
|
102
|
+
|
|
103
|
+

|
|
104
|
+
|
|
105
|
+
### Key Search - Page-based Pagination
|
|
106
|
+
Search for keys with traditional page-based navigation.
|
|
107
|
+
|
|
108
|
+

|
|
109
|
+
|
|
110
|
+
### Key Search - Cursor-based Pagination
|
|
111
|
+
Efficient cursor-based pagination for large datasets.
|
|
112
|
+
|
|
113
|
+

|
|
114
|
+
|
|
115
|
+
### Key Detail - String Values
|
|
116
|
+
View and edit string key values with TTL management.
|
|
117
|
+
|
|
118
|
+

|
|
119
|
+
|
|
120
|
+
### Key Detail - Other data structures
|
|
121
|
+
Browse keys with more complex data structures such as hashes, lists, etc.
|
|
122
|
+
|
|
123
|
+

|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## Installation
|
|
127
|
+
|
|
128
|
+
### 1. Install the Package
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pip install dj-redis-panel
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 2. Add to Django Settings
|
|
135
|
+
|
|
136
|
+
Add `dj_redis_panel` to your `INSTALLED_APPS`:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
INSTALLED_APPS = [
|
|
140
|
+
'django.contrib.admin',
|
|
141
|
+
'django.contrib.auth',
|
|
142
|
+
'django.contrib.contenttypes',
|
|
143
|
+
'django.contrib.sessions',
|
|
144
|
+
'django.contrib.messages',
|
|
145
|
+
'django.contrib.staticfiles',
|
|
146
|
+
'dj_redis_panel', # Add this line
|
|
147
|
+
# ... your other apps
|
|
148
|
+
]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 3. Configure Redis Instances
|
|
152
|
+
|
|
153
|
+
Add the Django Redis Panel configuration to your Django settings:
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
DJ_REDIS_PANEL_SETTINGS = {
|
|
157
|
+
# Global feature flags (can be overridden per instance)
|
|
158
|
+
"ALLOW_KEY_DELETE": False,
|
|
159
|
+
"ALLOW_KEY_EDIT": True,
|
|
160
|
+
"ALLOW_TTL_UPDATE": True,
|
|
161
|
+
"CURSOR_PAGINATED_SCAN": False,
|
|
162
|
+
|
|
163
|
+
"INSTANCES": {
|
|
164
|
+
"default": {
|
|
165
|
+
"description": "Default Redis Instance",
|
|
166
|
+
"host": "127.0.0.1",
|
|
167
|
+
"port": 6379,
|
|
168
|
+
"db": 0,
|
|
169
|
+
# Optional: override global settings for this instance
|
|
170
|
+
"features": {
|
|
171
|
+
"ALLOW_KEY_DELETE": True,
|
|
172
|
+
"CURSOR_PAGINATED_SCAN": True,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
"other_instance": {
|
|
176
|
+
"description": "Cache Redis Instance",
|
|
177
|
+
"url": "rediss://127.0.0.1:6379",
|
|
178
|
+
},
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 4. Include URLs
|
|
184
|
+
|
|
185
|
+
Add the Redis Panel URLs to your main `urls.py`:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from django.contrib import admin
|
|
189
|
+
from django.urls import path, include
|
|
190
|
+
|
|
191
|
+
urlpatterns = [
|
|
192
|
+
path('admin/', admin.site.urls),
|
|
193
|
+
path('admin/redis/', include('dj_redis_panel.urls')), # Add this line
|
|
194
|
+
]
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### 5. Run Migrations and Create Superuser
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
python manage.py migrate
|
|
201
|
+
python manage.py createsuperuser # If you don't have an admin user
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 6. Access the Panel
|
|
205
|
+
|
|
206
|
+
1. Start your Django development server:
|
|
207
|
+
```bash
|
|
208
|
+
python manage.py runserver
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
2. Navigate to the Django admin at `http://127.0.0.1:8000/admin/`
|
|
212
|
+
|
|
213
|
+
3. Look for the "DJ_REDIS_PANEL" section in the admin interface
|
|
214
|
+
|
|
215
|
+
4. Click "Manage Redis keys and values" to start browsing your Redis instances
|
|
216
|
+
|
|
217
|
+
## Configuration Options
|
|
218
|
+
|
|
219
|
+
### Global Settings
|
|
220
|
+
|
|
221
|
+
| Setting | Default | Description |
|
|
222
|
+
|---------|---------|-------------|
|
|
223
|
+
| `ALLOW_KEY_DELETE` | `False` | Allow deletion of Redis keys |
|
|
224
|
+
| `ALLOW_KEY_EDIT` | `True` | Allow editing of key values |
|
|
225
|
+
| `ALLOW_TTL_UPDATE` | `True` | Allow updating key TTL (expiration) |
|
|
226
|
+
| `CURSOR_PAGINATED_SCAN` | `False` | Use cursor-based pagination instead of page-based |
|
|
227
|
+
|
|
228
|
+
### Instance Configuration
|
|
229
|
+
|
|
230
|
+
Each Redis instance can be configured with:
|
|
231
|
+
|
|
232
|
+
#### Connection via Host/Port:
|
|
233
|
+
```python
|
|
234
|
+
"instance_name": {
|
|
235
|
+
"description": "Human-readable description",
|
|
236
|
+
"host": "127.0.0.1",
|
|
237
|
+
"port": 6379,
|
|
238
|
+
"db": 0, # Optional, default: 0
|
|
239
|
+
"password": "password", # Optional
|
|
240
|
+
"features": { # Optional: override global settings
|
|
241
|
+
"ALLOW_KEY_DELETE": True,
|
|
242
|
+
},
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
#### Connection via URL:
|
|
247
|
+
```python
|
|
248
|
+
"instance_name": {
|
|
249
|
+
"description": "Human-readable description",
|
|
250
|
+
"url": "redis://user:password@host:port/db",
|
|
251
|
+
"features": { # Optional: override global settings
|
|
252
|
+
"CURSOR_PAGINATED_SCAN": True,
|
|
253
|
+
},
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Feature Flags
|
|
258
|
+
|
|
259
|
+
Feature flags can be set globally and overridden per instance:
|
|
260
|
+
|
|
261
|
+
- **`ALLOW_KEY_DELETE`**: Controls whether the delete button is enabled
|
|
262
|
+
- **`ALLOW_KEY_EDIT`**: Controls whether key values can be modified
|
|
263
|
+
- **`ALLOW_TTL_UPDATE`**: Controls whether key expiration can be updated
|
|
264
|
+
- **`CURSOR_PAGINATED_SCAN`**: Chooses pagination method (cursor vs. page-based)
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Development Setup
|
|
273
|
+
|
|
274
|
+
If you want to contribute to this project or set it up for local development:
|
|
275
|
+
|
|
276
|
+
### Prerequisites
|
|
277
|
+
|
|
278
|
+
- Python 3.9 or higher
|
|
279
|
+
- Redis server running locally
|
|
280
|
+
- Git
|
|
281
|
+
- Autoconf
|
|
282
|
+
|
|
283
|
+
### 1. Clone the Repository
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
git clone https://github.com/yassi/dj-redis-panel.git
|
|
287
|
+
cd dj-redis-panel
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 2. Create Virtual Environment
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
python -m venv venv
|
|
294
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### 3. Install dj-redis-panel inside of your virtualenv
|
|
298
|
+
|
|
299
|
+
A make file is included in the repository root with multiple commands for building
|
|
300
|
+
and maintaining this project. The best approach is to start by using one of the
|
|
301
|
+
package installation commands found below:
|
|
302
|
+
```bash
|
|
303
|
+
# Build and install a wheel for this project
|
|
304
|
+
# Also install all dev dependencies such as pytest and other utilities
|
|
305
|
+
make install_dev
|
|
306
|
+
|
|
307
|
+
# Build and install a wheel for this project
|
|
308
|
+
make install
|
|
309
|
+
|
|
310
|
+
# build and install all dev dependencies and run all tests
|
|
311
|
+
make test
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### 4. Set Up Example Project
|
|
315
|
+
|
|
316
|
+
The repository includes an example Django project for development and testing:
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
cd example_project
|
|
320
|
+
python manage.py migrate
|
|
321
|
+
python manage.py createsuperuser
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### 5. Populate Test Data (Optional)
|
|
325
|
+
An optional CLI tool for populating redis keys automatically is included in the
|
|
326
|
+
example django project in this code base.
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
python manage.py populate_redis
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
This command will populate your Redis instance with sample data for testing.
|
|
333
|
+
|
|
334
|
+
### 6. Run the Development Server
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
python manage.py runserver
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Visit `http://127.0.0.1:8000/admin/` to access the Django admin with Redis Panel.
|
|
341
|
+
|
|
342
|
+
### 7. Running Tests
|
|
343
|
+
|
|
344
|
+
The project includes a comprehensive test suite. You can run them by using make or
|
|
345
|
+
by invoking pytest directly:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
# run using make which will also install all dependencies (recommended)
|
|
349
|
+
make test
|
|
350
|
+
|
|
351
|
+
# run using pytest directly
|
|
352
|
+
pytest tests/
|
|
353
|
+
|
|
354
|
+
# Run with coverage
|
|
355
|
+
pytest tests/ --cov=dj_redis_panel
|
|
356
|
+
|
|
357
|
+
# Run specific test file
|
|
358
|
+
pytest tests/test_views.py
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**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.
|
|
362
|
+
|
|
363
|
+
### 8. Dockerized Redis
|
|
364
|
+
|
|
365
|
+
Test for this project (as well as any active development) require an active redis installation.
|
|
366
|
+
Although not required, a docker-compose file is included to allow for easy creation of local
|
|
367
|
+
redis instances.
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
# Start Redis on localhost and the usual port 6379
|
|
371
|
+
docker-compose up redis -d
|
|
372
|
+
```
|