Skip to main content

A Django Admin panel for browsing and inspecting Django cache backends

Project description

Django Cache Panel

A Django Admin panel for browsing, inspecting, and managing Django cache backends defined in your CACHES setting.

Django Cache Panel - Instance List

Docs

https://yassi.github.io/dj-cache-panel/

Features

  • Browse Cache Keys: Search and filter cache keys with pattern matching
  • Key Management: View, edit, and delete cache keys with support for all data types
  • Feature Toggles: Granular control over operations (delete, edit, TTL updates)
  • 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 cache backends with different configurations

Supported Cache Data Types

  • String: View and edit string values.

Project Structure

dj-cache-panel/
├── dj_cache_panel/          # Main package
│   ├── templates/           # Django templates
│   ├── cache_utils.py       # Cache 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+

Screenshots

Django Admin Integration

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

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

Admin Home

Caches Overview

Monitor your cache instances with detailed metrics and database information.

Instance Overview

Installation

1. Install the Package

pip install dj-cache-panel

2. Add to Django Settings

Add dj_cache_panel to your INSTALLED_APPS:

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

3. Configure Cache Instances

Django cache panel will use the CACHES setting normally defined in django projects

CACHES = {
    ...
}

4. Include URLs

Add the Cache Panel URLs to your main urls.py:

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

urlpatterns = [
    path('admin/cache/', include('dj_cache_panel.urls')),  # Add this line
    path('admin/', admin.site.urls),
]

5. Run Migrations and Create Superuser

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:

    python manage.py runserver
    
  2. Navigate to the Django admin at http://127.0.0.1:8000/admin/

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

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

License

This project is licensed under the MIT License. See the 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

git clone https://github.com/yassi/dj-cache-panel.git
cd dj-cache-panel

2. Create Virtual Environment

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

3. Install dj-cache-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:

# Install all dependencies and dj-cache-panel into your current env
make install

4. Set Up Example Project

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

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

5. Populate Test Data (Optional)

An optional CLI tool for populating cache keys automatically is included in the example django project in this code base.

python manage.py populate_redis

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

6. Run the Development Server

python manage.py runserver

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

7. Running Tests

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

# build and install all dev dependencies and run all tests inside of docker container
make test

# Additionally generate coverage reports in multiple formats
make test_coverage

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.

8. Dockerized Cache Backend

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dj_cache_panel-0.1.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dj_cache_panel-0.1.0-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file dj_cache_panel-0.1.0.tar.gz.

File metadata

  • Download URL: dj_cache_panel-0.1.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.7

File hashes

Hashes for dj_cache_panel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e5399479bbbff80a33cc5e35137f76d169e9b220b1c3a31de61ba6fddb1f5f49
MD5 ba00f1924182c8bd5f2a8a095b8dd50e
BLAKE2b-256 4180e36eba7ea458f60c1c64f522832414a91950944607f094644f666a3fa3a8

See more details on using hashes here.

File details

Details for the file dj_cache_panel-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dj_cache_panel-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.7

File hashes

Hashes for dj_cache_panel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bf7c984e90ab7912067cc3daf95046000cd9a80aaa1dd9d543f2e3955a079c3
MD5 e73ba51ad44114c56fa488dfd823768f
BLAKE2b-256 4fbdad216162238507627f479284a8a4548e2057f30c496cb170c8b8a8eb43db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page