Skip to main content

A pluggable django app for media management.

Project description

Welcome to the documentation for django-medialibrary!

django-medialibrary is a pluggable django app that is able to store different media types (audio, video, image) and several versions of a given file in a transparent way.

The basic problam to solve is to store, retrieve and manage several versions of the same file in a seemless way. E.g. a user uploads a video that you will have to transcode into different formats. For the user you would like to show only a single media in his list of uploaded files, but you still want to serve all the generated files when necessary, moreover, if the user decides to delete his media you would like to delete all its versions.

The idea for this app is to have all this in an app-indepedent and easy to use and extend way.

Frontend API

There is no html frontend on purpose as we are using this app through APIs. The provided APIs out of the box are

  • /audio/, /video/, /image/ - to upload and list media elements of a given type

  • /<pk>/ - to get detailed info about a single media element

  • /<pk>/add/ - adds a relationship to the media element, expects a json of the form:

    {
            'model': 'app_name.model_name',
            'object_id': 1
    }

where app_name.model_name is the natural key of the model you are attaching.

Customizations

Besides the general django settings for file storage, there is a custom setting, the upload_to method used in the FileFields.:

import datetime
def setup_s3_route(instance, filename=None):
    today = datetime.datetime.today()
    return 'media/%s-%02d-%02d/%s' % (today.year, today.month, today.day,
                                          filename)
from medialibrary import utils
utils.setup_upload_route = setup_s3_route

You can set a custom argument for the limit_choices_to attribute on the ShelfRelation model. This way you can define which apps are allowed to have relationships to you media elements. (e.g. if you remove the attached records when you remove the media, you probably don’t want to attach django permission records to media). The default is no restricions!:

from medialibrary import utils
from django.db import models
utils.content_type_restriction = models.Q(app_label='auth', model='user')

Installation

pip install django-medialibrary

or you can find the project on github

Running the Tests

You can run the tests with via:

python setup.py test

or:

python runtests.py

Sponsors

This app was written at Pulilab while we were working on Vidzor.

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

django-medialibrary-1.1.1.tar.gz (12.7 kB view details)

Uploaded Source

File details

Details for the file django-medialibrary-1.1.1.tar.gz.

File metadata

File hashes

Hashes for django-medialibrary-1.1.1.tar.gz
Algorithm Hash digest
SHA256 506bb06158d51b8ad5ab8a36cbee0283cd777887d4f2510576642e3f78aed5f9
MD5 14b2fc0a59ea1925d84f96063fd2149f
BLAKE2b-256 ff95c13692f67ed61e27d3b794a2d6a8cf47e9c3ed8f134e1dbae1326f414ddb

See more details on using hashes here.

Supported by

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