Skip to main content
django-mediamanager
============

A central repository for registering scripts and styles for your applications. This is similar to how the Django form media works,
except that instead of including the media in each form, they are expected to be included in some base template so they are available on every page.

This is useful when dealing with single page web apps that use client side MVC frameworks like Backbone.js and you have multiple Django apps that are providing their own media.

## Installing

Install from pip
```
sudo pip install django_mediamanager
```

Add the content processor

```python
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS

TEMPLATE_CONTEXT_PROCESSORS += (
'django_mediamanager.context_processors.media_manager_processors',
)
```

Autodiscover any media within your applications. Add this to your main urls.py
```python
import django_mediamanager
django_mediamanager.autodiscover()
```

## Adding media
Your Django applications can provide a media.py file that registers all their media. The media files are expected to be in a "static" directory within your application

Example media.py
```python
import django_mediamanager

django_mediamanager.site.add_js((
"js/bootstrap.min.js",
"js/mycooljavascript.js",
))

django_mediamanager.site.add_css({
"all": (
"css/bootstrap.css",
"css/prettystyles.css",
)
})
```

## Including media in your templates
You can use the media manager's context processors to include all the registered media in your templates. For example:

```html
<html>
<head>
{{ALL_STYLES}}
</head>

<body>
{{ALL_SCRIPTS}}
</body>
</html>
```

Metadata

Release files for django-mediamanager 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-mediamanager 0.1.1
File Size Uploaded
django-mediamanager-0.1.1.tar.gz 3.1 kB Details

Release files / django-mediamanager-0.1.1.tar.gz

Download URL django-mediamanager-0.1.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c258a7123873af11cbb75a633a26c75d3667084c8851c978bb3a166608169ae2
BLAKE2b-256 checksum
How to use checksums
476e7c0edfbf172be034348d850deb248fed77cb3b6dfdc96b1e33726ce8036e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page