Settings — Static Media Manager v0.4 documentation

Static Media Manager v0.4 documentation

# Settings

- Table of Contents
- index
  modules
  next
  previous

# Settings

## STATIC_MEDIA_COPY_PATHS

The configuration of which path(s) should be copied where. It consists of a tuple of dicts. Each dict requires a `from` key and a `to` key.

    STATIC_MEDIA_COPY_PATHS = (
        {'from': MEDIA_ROOT, 'to': '/mnt/MediaServer/media/'},
    )

If you are copying everything from your `MEDIA_ROOT`, the above configuration would suffice. You can get more specific, as well.

    STATIC_MEDIA_COPY_PATHS = (
        {'from': MEDIA_ROOT+'/css/', 'to': '/mnt/MediaServer/media/css/'},
        {'from': MEDIA_ROOT+'/js/', 'to': '/mnt/MediaServer2/media/js/'},
        {'from': MEDIA_ROOT+'/img/', 'to': '/mnt/MediaServer3/media/img/'},
    )

The string in the `from` entry can be relative to the project path, or absolute. It can point to a file or a directory.

## STATIC_MEDIA_PURGE_OLD_FILES

When copying a directory, should the directory at the new location be emptied first (`True`) or left as-is (`False`). The default is `True`.

## STATIC_MEDIA_COMPRESS_CSS

Should CSS files be compressed using a port of the YUI Compressor when copied (`True`) or left as-is (`False`). The default is `False`.

The compression simply removes excess whitespace and comments and shortens colors and zero measurements. It does not alter any rules or combine any rule attributes. See CSS Compression for more detailed information.

## STATIC_MEDIA_COMPRESS_JS

Should Javascript files be compressed using a port of Douglas Crockford’s jsmin. The default is `False`.

## STATIC_MEDIA_JS_COMPRESSION_CMD

Which external javascript compression command to use. The command string can use `%(outfile)s` and `%(infile)s` placeholders. If the value is `None` then the internal `jsmin` library is used when STATIC_MEDIA_COMPRESS_JS is `True`. The default is `None` (Use the internal compression)

## STATIC_MEDIA_APP_MEDIA_PATH

Where should the contents of the media directory inside each entry in `INSTALLED_APPS` be installed? If the value is `None` then application media will not be copied. The default is `MEDIA_ROOT`.

Application media will not overwrite existing files, so it is possible for you to override one, several or all of the files in a given application’s media.

## STATIC_MEDIA_EXCLUDE_APPS

List of apps to exclude when copying media to `APP_MEDIA_PATH`. Needs to match the name as listed in `INSTALLED_APPS`.

## STATIC_MEDIA_DJANGO_ADMIN_DIR_NAME

The media for Django’s `contrib.admin` application doesn’t follow the de facto standard of enclosing an app’s media within a directory of the app’s name; its css files are in `css`, its images are in `img`, etc.

To avoid potential conflicts with other media, this setting allows you to add the admin media into a directory within your `STATIC_MEDIA_APP_MEDIA_PATH`. By default, it is `admin-media`.

Make sure you set your ADMIN_MEDIA_PREFIX to `/admin-media/` or whatever else you set this to.

## STATIC_MEDIA_FILE_COMBINATIONS

A dictionary mapping a (new) file to a combination/concatenation of several other files. The concatenation is done in the order of the list. The resulting file will be compressed according to the `COMPRESS_CSS` and `COMPRESS_JS` settings.

For example, to combine three CSS files into one `combo.css` file:

    STATIC_MEDIA_FILE_COMBINATIONS = {
        MEDIA_ROOT+'/css/combo.css': [
            MEDIA_ROOT+'/css/base.css',
            MEDIA_ROOT+'/css/forms.css',
            MEDIA_ROOT+'/css/coolui.css'],
    }

Note

File combinations are done before anything else, so make the destination path for combination files be in a directory configured in a `from` key in STATIC_MEDIA_COPY_PATHS.

The original files are not touched and the destination file can safely reside with them. The default setting is an empty dictionary.

## STATIC_URL

In order to segregate user uploaded content from the site content, you can use the `STATIC_URL` and the static url `staticmediamgr.context_processor.static_url` to keep things separate.

The default is `STATIC_URL = MEDIA_URL`