Skip to main content

Process every media request, if media not present locally, and try to obtain in another location

Project description

Django Media Placeholder

This project override django static media and storage(optional), for process every media request, if media not present locally, and try to obtain in another location

Its great for dev, homolog and QA ambients because no need to copy production media every time.

Installation

  1. Install the package with:

    pip install django-media-placeholder

  2. Uninstall the package with:

    pip uninstall django-media-placeholder

  3. Add and URL to your URLCONF:

    from django_media_placeholder.static import static
    urlpatterns = [
        ...
    ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    
  4. On settings.py, set MEDIA_URL to point to it

    ...
    STATIC_URL = '/static/'
    MEDIA_URL = '/media/'
    MEDIA_ROOT = os.path.join(DATA_DIR, 'media')
    STATIC_ROOT = os.path.join(DATA_DIR, 'static')
    ALTERNATIVE_MEDIA_URL = 'Url to Get image not present in locally'
    
  5. If use thumbanails, set DEFAULT_FILE_STORAGE to new storage, (thumbnails's libs generate and get image directly in disk, no request to media path):

    DEFAULT_FILE_STORAGE = 'django_media_placeholder.custom_storage.OverwritingStorage'
    

Project details


Release history Release notifications

This version

0.1

Download files

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

Files for django-media-placeholder, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_media_placeholder-0.1.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page