dj-cache-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_cache_panel-0.1.0/LICENSE +21 -0
- dj_cache_panel-0.1.0/MANIFEST.in +2 -0
- dj_cache_panel-0.1.0/PKG-INFO +273 -0
- dj_cache_panel-0.1.0/README.md +228 -0
- dj_cache_panel-0.1.0/dj_cache_panel/__init__.py +3 -0
- dj_cache_panel-0.1.0/dj_cache_panel/admin.py +27 -0
- dj_cache_panel-0.1.0/dj_cache_panel/apps.py +7 -0
- dj_cache_panel-0.1.0/dj_cache_panel/models.py +14 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/base.html +24 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/index.html +64 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/instance_overview.html +127 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_add.html +126 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_detail.html +190 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_detail_add.html +120 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_detail_pagination.html +71 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_detail_pagination_info.html +20 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_detail_value_hash.html +69 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_detail_value_list.html +69 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_detail_value_set.html +56 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_detail_value_string.html +31 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_detail_value_zset.html +69 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/key_search.html +215 -0
- dj_cache_panel-0.1.0/dj_cache_panel/templates/admin/dj_cache_panel/styles.css +508 -0
- dj_cache_panel-0.1.0/dj_cache_panel/urls.py +8 -0
- dj_cache_panel-0.1.0/dj_cache_panel/views.py +12 -0
- dj_cache_panel-0.1.0/dj_cache_panel.egg-info/PKG-INFO +273 -0
- dj_cache_panel-0.1.0/dj_cache_panel.egg-info/SOURCES.txt +32 -0
- dj_cache_panel-0.1.0/dj_cache_panel.egg-info/dependency_links.txt +1 -0
- dj_cache_panel-0.1.0/dj_cache_panel.egg-info/requires.txt +14 -0
- dj_cache_panel-0.1.0/dj_cache_panel.egg-info/top_level.txt +6 -0
- dj_cache_panel-0.1.0/pyproject.toml +117 -0
- dj_cache_panel-0.1.0/setup.cfg +4 -0
- dj_cache_panel-0.1.0/setup.py +3 -0
- dj_cache_panel-0.1.0/tests/test_admin.py +75 -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,273 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dj-cache-panel
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Django Admin panel for browsing and inspecting Django cache backends
|
|
5
|
+
Author: Yasser Toruno
|
|
6
|
+
Maintainer: Yasser Toruno
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://yassi.github.io/dj-cache-panel/
|
|
9
|
+
Project-URL: Documentation, https://yassi.github.io/dj-cache-panel/
|
|
10
|
+
Project-URL: Repository, https://github.com/yassi/dj-cache-panel
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/yassi/dj-cache-panel/issues
|
|
12
|
+
Keywords: django,cache,admin,panel,caching,django-cache
|
|
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: Framework :: Django :: 6.0
|
|
19
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
26
|
+
Classifier: Operating System :: OS Independent
|
|
27
|
+
Classifier: Intended Audience :: Developers
|
|
28
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
29
|
+
Requires-Python: >=3.9
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: Django>=4.2
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-django>=4.5.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-xdist>=3.2.0; extra == "dev"
|
|
38
|
+
Requires-Dist: pymemcache>=4.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: django-redis>=5.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: mkdocs-material>=9.1.12; extra == "dev"
|
|
41
|
+
Provides-Extra: build
|
|
42
|
+
Requires-Dist: build>=1.0.0; extra == "build"
|
|
43
|
+
Requires-Dist: twine>=4.0.0; extra == "build"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
# Django Cache Panel
|
|
47
|
+
|
|
48
|
+
A Django Admin panel for browsing, inspecting, and managing Django cache backends defined in your `CACHES` setting.
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
## Docs
|
|
53
|
+
|
|
54
|
+
[https://yassi.github.io/dj-cache-panel/](https://yassi.github.io/dj-cache-panel/)
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- **Browse Cache Keys**: Search and filter cache keys with pattern matching
|
|
59
|
+
- **Key Management**: View, edit, and delete cache keys with support for all data types
|
|
60
|
+
- **Feature Toggles**: Granular control over operations (delete, edit, TTL updates)
|
|
61
|
+
- **Django Admin Integration**: Seamless integration with Django admin styling and dark mode
|
|
62
|
+
- **Permission Control**: Respects Django admin permissions and staff-only access
|
|
63
|
+
- **Multiple Instances**: Support for multiple cache backends with different configurations
|
|
64
|
+
|
|
65
|
+
## Supported Cache Data Types
|
|
66
|
+
|
|
67
|
+
- **String**: View and edit string values.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Project Structure
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
dj-cache-panel/
|
|
74
|
+
├── dj_cache_panel/ # Main package
|
|
75
|
+
│ ├── templates/ # Django templates
|
|
76
|
+
│ ├── cache_utils.py # Cache utilities
|
|
77
|
+
│ ├── views.py # Django views
|
|
78
|
+
│ └── urls.py # URL patterns
|
|
79
|
+
├── example_project/ # Example Django project
|
|
80
|
+
├── tests/ # Test suite
|
|
81
|
+
├── images/ # Screenshots for README
|
|
82
|
+
└── requirements.txt # Development dependencies
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Requirements
|
|
86
|
+
|
|
87
|
+
- Python 3.9+
|
|
88
|
+
- Django 4.2+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## Screenshots
|
|
93
|
+
|
|
94
|
+
### Django Admin Integration
|
|
95
|
+
Seamlessly integrated into your Django admin interface. A new section for dj-cache-panel
|
|
96
|
+
will appear in the same places where your models appear.
|
|
97
|
+
|
|
98
|
+
**NOTE:** This application does not actually introduce any model or migrations.
|
|
99
|
+
|
|
100
|
+

|
|
101
|
+
|
|
102
|
+
### Caches Overview
|
|
103
|
+
Monitor your cache instances with detailed metrics and database information.
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
## Installation
|
|
109
|
+
|
|
110
|
+
### 1. Install the Package
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pip install dj-cache-panel
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 2. Add to Django Settings
|
|
117
|
+
|
|
118
|
+
Add `dj_cache_panel` to your `INSTALLED_APPS`:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
INSTALLED_APPS = [
|
|
122
|
+
'django.contrib.admin',
|
|
123
|
+
'django.contrib.auth',
|
|
124
|
+
'django.contrib.contenttypes',
|
|
125
|
+
'django.contrib.sessions',
|
|
126
|
+
'django.contrib.messages',
|
|
127
|
+
'django.contrib.staticfiles',
|
|
128
|
+
'dj_cache_panel', # Add this line
|
|
129
|
+
# ... your other apps
|
|
130
|
+
]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 3. Configure Cache Instances
|
|
134
|
+
|
|
135
|
+
Django cache panel will use the `CACHES` setting normally defined in django projects
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
CACHES = {
|
|
139
|
+
...
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
### 4. Include URLs
|
|
145
|
+
|
|
146
|
+
Add the Cache Panel URLs to your main `urls.py`:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from django.contrib import admin
|
|
150
|
+
from django.urls import path, include
|
|
151
|
+
|
|
152
|
+
urlpatterns = [
|
|
153
|
+
path('admin/cache/', include('dj_cache_panel.urls')), # Add this line
|
|
154
|
+
path('admin/', admin.site.urls),
|
|
155
|
+
]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 5. Run Migrations and Create Superuser
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
python manage.py migrate
|
|
162
|
+
python manage.py createsuperuser # If you don't have an admin user
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 6. Access the Panel
|
|
166
|
+
|
|
167
|
+
1. Start your Django development server:
|
|
168
|
+
```bash
|
|
169
|
+
python manage.py runserver
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
2. Navigate to the Django admin at `http://127.0.0.1:8000/admin/`
|
|
173
|
+
|
|
174
|
+
3. Look for the "DJ_CACHE_PANEL" section in the admin interface
|
|
175
|
+
|
|
176
|
+
4. Click "Manage Cache keys and values" to start browsing your cache instances
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Development Setup
|
|
187
|
+
|
|
188
|
+
If you want to contribute to this project or set it up for local development:
|
|
189
|
+
|
|
190
|
+
### Prerequisites
|
|
191
|
+
|
|
192
|
+
- Python 3.9 or higher
|
|
193
|
+
- Redis server running locally
|
|
194
|
+
- Git
|
|
195
|
+
- Autoconf
|
|
196
|
+
|
|
197
|
+
### 1. Clone the Repository
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
git clone https://github.com/yassi/dj-cache-panel.git
|
|
201
|
+
cd dj-cache-panel
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 2. Create Virtual Environment
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
python -m venv venv
|
|
208
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### 3. Install dj-cache-panel inside of your virtualenv
|
|
212
|
+
|
|
213
|
+
A make file is included in the repository root with multiple commands for building
|
|
214
|
+
and maintaining this project. The best approach is to start by using one of the
|
|
215
|
+
package installation commands found below:
|
|
216
|
+
```bash
|
|
217
|
+
# Install all dependencies and dj-cache-panel into your current env
|
|
218
|
+
make install
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### 4. Set Up Example Project
|
|
222
|
+
|
|
223
|
+
The repository includes an example Django project for development and testing:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
cd example_project
|
|
227
|
+
python manage.py migrate
|
|
228
|
+
python manage.py createsuperuser
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 5. Populate Test Data (Optional)
|
|
232
|
+
An optional CLI tool for populating cache keys automatically is included in the
|
|
233
|
+
example django project in this code base.
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
python manage.py populate_redis
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
This command will populate your cache instance with sample data for testing.
|
|
240
|
+
|
|
241
|
+
### 6. Run the Development Server
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
python manage.py runserver
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Visit `http://127.0.0.1:8000/admin/` to access the Django admin with Cache Panel.
|
|
248
|
+
|
|
249
|
+
### 7. Running Tests
|
|
250
|
+
|
|
251
|
+
The project includes a comprehensive test suite. You can run them by using make or
|
|
252
|
+
by invoking pytest directly:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# build and install all dev dependencies and run all tests inside of docker container
|
|
256
|
+
make test
|
|
257
|
+
|
|
258
|
+
# Additionally generate coverage reports in multiple formats
|
|
259
|
+
make test_coverage
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Note**: Tests require a running cache backend (e.g., Redis) on `127.0.0.1:6379`. The tests use databases 13, 14, and 15 for isolation and automatically clean up after each test.
|
|
263
|
+
|
|
264
|
+
### 8. Dockerized Cache Backend
|
|
265
|
+
|
|
266
|
+
Test for this project (as well as any active development) require an active cache backend installation.
|
|
267
|
+
Although not required, a docker-compose file is included to allow for easy creation of local
|
|
268
|
+
cache instances using redis, memcached, local memory, etc.
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# Start Redis on localhost and the usual port 6379
|
|
272
|
+
docker-compose up -d
|
|
273
|
+
```
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# Django Cache Panel
|
|
2
|
+
|
|
3
|
+
A Django Admin panel for browsing, inspecting, and managing Django cache backends defined in your `CACHES` setting.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Docs
|
|
8
|
+
|
|
9
|
+
[https://yassi.github.io/dj-cache-panel/](https://yassi.github.io/dj-cache-panel/)
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Browse Cache Keys**: Search and filter cache keys with pattern matching
|
|
14
|
+
- **Key Management**: View, edit, and delete cache keys with support for all data types
|
|
15
|
+
- **Feature Toggles**: Granular control over operations (delete, edit, TTL updates)
|
|
16
|
+
- **Django Admin Integration**: Seamless integration with Django admin styling and dark mode
|
|
17
|
+
- **Permission Control**: Respects Django admin permissions and staff-only access
|
|
18
|
+
- **Multiple Instances**: Support for multiple cache backends with different configurations
|
|
19
|
+
|
|
20
|
+
## Supported Cache Data Types
|
|
21
|
+
|
|
22
|
+
- **String**: View and edit string values.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Project Structure
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
dj-cache-panel/
|
|
29
|
+
├── dj_cache_panel/ # Main package
|
|
30
|
+
│ ├── templates/ # Django templates
|
|
31
|
+
│ ├── cache_utils.py # Cache utilities
|
|
32
|
+
│ ├── views.py # Django views
|
|
33
|
+
│ └── urls.py # URL patterns
|
|
34
|
+
├── example_project/ # Example Django project
|
|
35
|
+
├── tests/ # Test suite
|
|
36
|
+
├── images/ # Screenshots for README
|
|
37
|
+
└── requirements.txt # Development dependencies
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
- Python 3.9+
|
|
43
|
+
- Django 4.2+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Screenshots
|
|
48
|
+
|
|
49
|
+
### Django Admin Integration
|
|
50
|
+
Seamlessly integrated into your Django admin interface. A new section for dj-cache-panel
|
|
51
|
+
will appear in the same places where your models appear.
|
|
52
|
+
|
|
53
|
+
**NOTE:** This application does not actually introduce any model or migrations.
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
### Caches Overview
|
|
58
|
+
Monitor your cache instances with detailed metrics and database information.
|
|
59
|
+
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
### 1. Install the Package
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install dj-cache-panel
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 2. Add to Django Settings
|
|
72
|
+
|
|
73
|
+
Add `dj_cache_panel` to your `INSTALLED_APPS`:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
INSTALLED_APPS = [
|
|
77
|
+
'django.contrib.admin',
|
|
78
|
+
'django.contrib.auth',
|
|
79
|
+
'django.contrib.contenttypes',
|
|
80
|
+
'django.contrib.sessions',
|
|
81
|
+
'django.contrib.messages',
|
|
82
|
+
'django.contrib.staticfiles',
|
|
83
|
+
'dj_cache_panel', # Add this line
|
|
84
|
+
# ... your other apps
|
|
85
|
+
]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 3. Configure Cache Instances
|
|
89
|
+
|
|
90
|
+
Django cache panel will use the `CACHES` setting normally defined in django projects
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
CACHES = {
|
|
94
|
+
...
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### 4. Include URLs
|
|
100
|
+
|
|
101
|
+
Add the Cache Panel URLs to your main `urls.py`:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from django.contrib import admin
|
|
105
|
+
from django.urls import path, include
|
|
106
|
+
|
|
107
|
+
urlpatterns = [
|
|
108
|
+
path('admin/cache/', include('dj_cache_panel.urls')), # Add this line
|
|
109
|
+
path('admin/', admin.site.urls),
|
|
110
|
+
]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 5. Run Migrations and Create Superuser
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
python manage.py migrate
|
|
117
|
+
python manage.py createsuperuser # If you don't have an admin user
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 6. Access the Panel
|
|
121
|
+
|
|
122
|
+
1. Start your Django development server:
|
|
123
|
+
```bash
|
|
124
|
+
python manage.py runserver
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
2. Navigate to the Django admin at `http://127.0.0.1:8000/admin/`
|
|
128
|
+
|
|
129
|
+
3. Look for the "DJ_CACHE_PANEL" section in the admin interface
|
|
130
|
+
|
|
131
|
+
4. Click "Manage Cache keys and values" to start browsing your cache instances
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Development Setup
|
|
142
|
+
|
|
143
|
+
If you want to contribute to this project or set it up for local development:
|
|
144
|
+
|
|
145
|
+
### Prerequisites
|
|
146
|
+
|
|
147
|
+
- Python 3.9 or higher
|
|
148
|
+
- Redis server running locally
|
|
149
|
+
- Git
|
|
150
|
+
- Autoconf
|
|
151
|
+
|
|
152
|
+
### 1. Clone the Repository
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
git clone https://github.com/yassi/dj-cache-panel.git
|
|
156
|
+
cd dj-cache-panel
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 2. Create Virtual Environment
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
python -m venv venv
|
|
163
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 3. Install dj-cache-panel inside of your virtualenv
|
|
167
|
+
|
|
168
|
+
A make file is included in the repository root with multiple commands for building
|
|
169
|
+
and maintaining this project. The best approach is to start by using one of the
|
|
170
|
+
package installation commands found below:
|
|
171
|
+
```bash
|
|
172
|
+
# Install all dependencies and dj-cache-panel into your current env
|
|
173
|
+
make install
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 4. Set Up Example Project
|
|
177
|
+
|
|
178
|
+
The repository includes an example Django project for development and testing:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
cd example_project
|
|
182
|
+
python manage.py migrate
|
|
183
|
+
python manage.py createsuperuser
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 5. Populate Test Data (Optional)
|
|
187
|
+
An optional CLI tool for populating cache keys automatically is included in the
|
|
188
|
+
example django project in this code base.
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
python manage.py populate_redis
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
This command will populate your cache instance with sample data for testing.
|
|
195
|
+
|
|
196
|
+
### 6. Run the Development Server
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
python manage.py runserver
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Visit `http://127.0.0.1:8000/admin/` to access the Django admin with Cache Panel.
|
|
203
|
+
|
|
204
|
+
### 7. Running Tests
|
|
205
|
+
|
|
206
|
+
The project includes a comprehensive test suite. You can run them by using make or
|
|
207
|
+
by invoking pytest directly:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# build and install all dev dependencies and run all tests inside of docker container
|
|
211
|
+
make test
|
|
212
|
+
|
|
213
|
+
# Additionally generate coverage reports in multiple formats
|
|
214
|
+
make test_coverage
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Note**: Tests require a running cache backend (e.g., Redis) on `127.0.0.1:6379`. The tests use databases 13, 14, and 15 for isolation and automatically clean up after each test.
|
|
218
|
+
|
|
219
|
+
### 8. Dockerized Cache Backend
|
|
220
|
+
|
|
221
|
+
Test for this project (as well as any active development) require an active cache backend installation.
|
|
222
|
+
Although not required, a docker-compose file is included to allow for easy creation of local
|
|
223
|
+
cache instances using redis, memcached, local memory, etc.
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Start Redis on localhost and the usual port 6379
|
|
227
|
+
docker-compose up -d
|
|
228
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
from django.http import HttpResponseRedirect
|
|
3
|
+
from django.urls import reverse
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from .models import CachePanelPlaceholder
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@admin.register(CachePanelPlaceholder)
|
|
10
|
+
class CachePanelPlaceholderAdmin(admin.ModelAdmin):
|
|
11
|
+
def changelist_view(self, request, extra_context=None):
|
|
12
|
+
# The @staff_member_required decorator on the view will handle auth
|
|
13
|
+
return HttpResponseRedirect(reverse("dj_cache_panel:index"))
|
|
14
|
+
|
|
15
|
+
def has_add_permission(self, request):
|
|
16
|
+
return False
|
|
17
|
+
|
|
18
|
+
def has_change_permission(self, request, obj=None):
|
|
19
|
+
# Allow staff members to "view" the Cache panel
|
|
20
|
+
return request.user.is_staff
|
|
21
|
+
|
|
22
|
+
def has_delete_permission(self, request, obj=None):
|
|
23
|
+
return False
|
|
24
|
+
|
|
25
|
+
def has_view_permission(self, request, obj=None):
|
|
26
|
+
# Allow staff members to view the Cache panel
|
|
27
|
+
return request.user.is_staff
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from django.db import models
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CachePanelPlaceholder(models.Model):
|
|
5
|
+
"""
|
|
6
|
+
This is a fake model used to create an entry in the admin panel for the cache panel.
|
|
7
|
+
When we register this app with the admin site, it is configured to simply load
|
|
8
|
+
the cache panel templates.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
class Meta:
|
|
12
|
+
managed = False
|
|
13
|
+
verbose_name = "Django Cache Panel"
|
|
14
|
+
verbose_name_plural = "Django Cache Panel"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{% extends "admin/base_site.html" %}
|
|
2
|
+
{% load i18n admin_urls static admin_list %}
|
|
3
|
+
|
|
4
|
+
{% block title %}{{ title }} | DJ Cache Panel{% endblock %}
|
|
5
|
+
|
|
6
|
+
{% block extrahead %}
|
|
7
|
+
<style type="text/css">
|
|
8
|
+
{% include "admin/dj_cache_panel/styles.css" %}
|
|
9
|
+
</style>
|
|
10
|
+
{% endblock %}
|
|
11
|
+
|
|
12
|
+
{% block branding %}
|
|
13
|
+
<h1 id="site-name"><a href="{% url 'dj_cache_panel:index' %}">DJ Cache Panel</a></h1>
|
|
14
|
+
{% endblock %}
|
|
15
|
+
|
|
16
|
+
{% block breadcrumbs %}
|
|
17
|
+
<div class="breadcrumbs">
|
|
18
|
+
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
|
19
|
+
› {{ title }}
|
|
20
|
+
</div>
|
|
21
|
+
{% endblock %}
|
|
22
|
+
|
|
23
|
+
{% block content %}
|
|
24
|
+
{% endblock %}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{% extends "admin/dj_cache_panel/base.html" %}
|
|
2
|
+
{% load i18n admin_urls static admin_list %}
|
|
3
|
+
|
|
4
|
+
{% block content %}
|
|
5
|
+
<div class="module">
|
|
6
|
+
{% if caches %}
|
|
7
|
+
<h2>{% trans 'Cache Instances' %}</h2>
|
|
8
|
+
<br>
|
|
9
|
+
<div class="results">
|
|
10
|
+
<table id="result_list">
|
|
11
|
+
<thead>
|
|
12
|
+
<tr>
|
|
13
|
+
<th>Cache Name</th>
|
|
14
|
+
<th>Backend</th>
|
|
15
|
+
</tr>
|
|
16
|
+
</thead>
|
|
17
|
+
<tbody>
|
|
18
|
+
{% for cache_name, cache_config in caches.items %}
|
|
19
|
+
<tr>
|
|
20
|
+
<td>{{ cache_name }}</td>
|
|
21
|
+
<td>{{ cache_config.BACKEND }}</td>
|
|
22
|
+
</tr>
|
|
23
|
+
{% endfor %}
|
|
24
|
+
</table>
|
|
25
|
+
</div>
|
|
26
|
+
{% else %}
|
|
27
|
+
<div class="aligned">
|
|
28
|
+
<fieldset class="module">
|
|
29
|
+
<h2>{% trans 'Cache Configuration Required' %}</h2>
|
|
30
|
+
|
|
31
|
+
<div class="form-row">
|
|
32
|
+
<div class="help-text">
|
|
33
|
+
<p>{% trans 'To use the Cache panel, you must configure cache instances in your Django settings.' %}</p>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div class="form-row">
|
|
38
|
+
<h3>{% trans 'Please add a configuration dictionary to your settings.py like the example below:' %}</h3>
|
|
39
|
+
<fieldset class="collapse">
|
|
40
|
+
<div class="form-row">
|
|
41
|
+
<textarea readonly rows="25" class="vLargeTextField" style="font-family: monospace; width: 100%;">
|
|
42
|
+
CACHES = {
|
|
43
|
+
"default": {
|
|
44
|
+
"BACKEND": "django.core.cache.backends.redis.RedisCache",
|
|
45
|
+
"LOCATION": "redis://127.0.0.1:6379",
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</textarea>
|
|
49
|
+
</div>
|
|
50
|
+
</fieldset>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
<div class="form-row">
|
|
56
|
+
<div class="help-text">
|
|
57
|
+
<p><strong>{% trans 'After adding the configuration, restart your Django server to see your Cache instances.' %}</strong></p>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</fieldset>
|
|
61
|
+
</div>
|
|
62
|
+
{% endif %}
|
|
63
|
+
</div>
|
|
64
|
+
{% endblock %}
|