Skip to main content

Portable media infrastructure for Django.

Project description

WBR Media

Python Django Status Tests

Portable media infrastructure for Django.

wbr_media provides a clean, consistent way to store, manage, render, and now port media assets between Django installations without requiring a full CMS.


📷 Screenshots

Media Index

A lightweight media library view with previews and metadata.

Media index

Media Detail

Asset inspection with preview, metadata, and image properties.

Media detail


Why WBR Media?

Django provides excellent support for uploading files, but it intentionally leaves higher-level media management to individual applications.

wbr_media fills that gap by providing:

  • structured media storage
  • automatic metadata extraction
  • consistent template rendering
  • safe file lifecycle management
  • complete import/export portability

without introducing the complexity of a full content management system.


Why not just use Django FileField?

You certainly can—but most projects eventually end up rebuilding the same infrastructure:

  • metadata extraction
  • image dimension detection
  • MIME type detection
  • cleanup of replaced files
  • cleanup of deleted files
  • rendering helpers
  • import/export tooling

wbr_media packages those capabilities into a small, reusable application.


✨ Features

  • Structured MediaAsset model
  • Automatic file metadata extraction
  • Image-specific metadata (dimensions, format, alpha, DPI)
  • Safe file replacement and deletion
  • Flexible template rendering
  • Media portability with checksum validation
  • Complete export/import workflow for media libraries

📸 Rendering Media

Load the template tags:

{% load wbr_media_tags %}

Render using the default presentation:

{% render_media asset %}

Or customize the presentation:

{% render_media asset display="bare" class_name="card-image" %}

Optional Arguments

Argument Description
size Named size (currently returns the original file)
display figure (default for images), bare, or link (default for non-images)
class_name CSS class applied to the rendered element

🚀 Installation

pip install -e .

Add the application:

INSTALLED_APPS = [
    ...
    "wbr_media",
]

Configure the upload location.

Note: The configured upload path is appended to Django's MEDIA_ROOT.

WBR_MEDIA = {
    "UPLOAD_TO": "wbr_media/%Y/%m/",
}

Run migrations:

python manage.py migrate

⚙️ Configuration

Available settings:

WBR_MEDIA = {
    "UPLOAD_TO": "assets/originals/%Y/%m/",
}

📦 Media Portability

One of the primary goals of wbr_media is complete portability.

A media library consists of two distinct pieces:

  • Media metadata stored in the database
  • Physical media files stored on disk

wbr_media exports and restores both as a single portable bundle.

Exporting a Media Library

Create a complete export:

python manage.py export_wbr_media --output ./backups/wbr_media_export.zip

The export process:

  1. Exports all MediaAsset and ImageMetadata records.
  2. Copies physical media assets.
  3. Generates a manifest describing every exported file.
  4. Calculates SHA-256 checksums for each asset.
  5. Validates the completed archive.
  6. Produces a portable bundle.

Bundle Layout

wbr_media_export.zip
├── data.json
└── media_export.zip
    ├── media_manifest.json
    └── files/

The media manifest records:

  • exported file path
  • existence
  • file size
  • SHA-256 checksum

These checksums are verified before any restore operation proceeds.


Importing a Media Library

Restore a previously exported bundle:

python manage.py import_wbr_media ./backups/wbr_media_export.zip

The import process:

  1. Opens the bundle.
  2. Validates the manifest.
  3. Verifies SHA-256 checksums.
  4. Restores physical media assets.
  5. Restores media database records.

If validation fails, restoration is aborted before modifying the destination installation.


Low-Level Commands

The application also exposes lower-level commands for working directly with physical media.

Export physical assets:

python manage.py export_media_files --output ./exports/media

Inspect a media archive:

python manage.py inspect_media_import ./exports/media_export.zip

Restore physical assets:

python manage.py restore_media_files ./exports/media_export.zip

These commands are primarily intended for development, debugging, and testing. In most cases, export_wbr_media and import_wbr_media should be preferred.


🧪 Development

A demo project is included.

cd demo
python manage.py runserver

Visit:

http://127.0.0.1:8000/media-demo/

Testing

Run the complete test suite:

pytest

📦 What This Is

  • A lightweight media layer for Django
  • Consistent media metadata management
  • Flexible template rendering
  • Safe file lifecycle management
  • Portable media transfer between installations

🚫 What This Is Not

  • A CMS
  • A digital asset management system
  • A replacement for WordPress or Drupal
  • A complete media workflow solution

wbr_media is intentionally focused on providing a clean infrastructure layer that can be integrated into larger Django applications.


🛣️ Roadmap

Future improvements include:

  • Generated image renditions
  • Pluggable storage backends
  • Media usage tracking
  • Project-specific rendering extensions

The project intentionally avoids becoming a full CMS.


📄 License

All Rights Reserved.

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

wbr_media-0.2.0.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

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

wbr_media-0.2.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file wbr_media-0.2.0.tar.gz.

File metadata

  • Download URL: wbr_media-0.2.0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wbr_media-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cc3a1c4bc878fc3229c135cd25d57fa21b653c34dce29d50d1f8d02279b099bc
MD5 2715b96622f7252699e5b7a6969919d6
BLAKE2b-256 5f92503c7fcc2dd82afa05ea072456cbb69533c2e4e1066b4e0ce5367ad22788

See more details on using hashes here.

Provenance

The following attestation bundles were made for wbr_media-0.2.0.tar.gz:

Publisher: publish.yaml on HolisticNetworkingNet/wbr_media

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wbr_media-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: wbr_media-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wbr_media-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 529704950a7224edb644a04b85769635b5d20a4a9d81e6111b8dcb5a5b4b8bbf
MD5 c7b2376d1691ec7aadfe83a6d90c83d3
BLAKE2b-256 6647ebdc2f242dfa563e2fe6f396d5d691aa1b3c428574b1754014d243bf9ba1

See more details on using hashes here.

Provenance

The following attestation bundles were made for wbr_media-0.2.0-py3-none-any.whl:

Publisher: publish.yaml on HolisticNetworkingNet/wbr_media

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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