Jump to >


class ExtensionStaticStorage(*args, **kwargs)[source]

Bases: django.core.files.storage.FileSystemStorage

Provides access to static files owned by an extension.

This is a thin wrapper around FileSystemStorage that determines the path to the static directory within the extension. It will only operate on files within that path.

source_dir = 'static'[source]
prefix = None[source]
__init__(extension, *args, **kwargs)[source]
class ExtensionFinder(*args, **kwargs)[source]

Bases: django.contrib.staticfiles.finders.BaseFinder

Finds static files within enabled extensions.

ExtensionFinder can list static files belonging to an extension, and find the path of a static file, given an extension ID and path.

All static files are expected to be in the form of ext/<extension_id>/<path>, where extension_id is the ID given to an extension (based on the full class path for the extension class).

An extension is only valid if it has a “static” directory.


alias of djblets.extensions.staticfiles.ExtensionStaticStorage

__init__(*args, **kwargs)[source]
find(path, all=False)[source]

Finds the real path to a static file, given a static path.

The path must start with “ext/<extension_id>/”. The files within will map to files within the extension’s “static” directory.

class PackagingCachedFilesStorage(*args, **kwargs)[source]

Bases: djblets.pipeline.storage.PipelineStorage

Looks up referenced static files from the current storage.

When one static file references another, Django assumes that the referenced file is in the same static storage and path as that of the parent. This prevents a bundled file (such as a .less file) in an extension from referencing an image or other file shipped with the main application.

This storage works around this by attempting to look up a storage matching the referenced path. If found, the paths from that storage will be used instead.

This behavior is only activated when Django performs a lookup as the result of a .css containing a url(...) or @import ....

__init__(*args, **kwargs)[source]
hashed_name(name, content=None)[source]

Look up and generate a hashed filename for the given filename.

This will attempt to find a storage that serves up the given filename. If found, the hashed data from that storage will be used instead.

If not found, then this falls back to the default functionality of either generating a hashed filename from the parent static file’s storage, or raising an exception about a missing file.

  • name (str) – The name of the file to look up.

  • content (str) – The content of the file, if known.


A resulting file path for the file, with a hash in the


Return type


__annotations__ = {}
class PackagingStorage(storage=None, *args, **kwargs)[source]

Bases: pipeline.finders.PipelineFinder

Looks up stored files when packaging an extension.

This is a special Pipeline static file storage implementation that can locate the proper Storage class when trying to find a file.

This works just like PipelineFinder, but can interface with PackagingFinder to trigger a lookup across all storages, since PackagingFinder by default limits to the extension’s static files.

__annotations__ = {}
class PackagingFinder(app_names=None, *args, **kwargs)[source]

Bases: django.contrib.staticfiles.finders.FileSystemFinder

Finds static media files for an extension.

This is used during packaging to list only static media files provided by the extension, but to allow looking up static media from all apps.

It works with PackagingStorage to do the appropriate lookup given the parameters passed.

Essentially, when collecting static media (using the collectstatic management command), Django will call list() on the finders, grabbing every known static file, and packaging those. For extensions, we don’t want to grab media files from the main apps, and want to limit only to the files bundled with the extension.

There are times when we do want to list all files, though. For example, when referencing definitions files provided by the project for .less files.

In the default case, PackagingFinder.list will only look up files from the extension, but if given an extra parameter that PackagingStorage can pass (used for finding referenced files), it will look through all storages.


alias of djblets.extensions.staticfiles.PackagingStorage

extension_static_dir = None[source]
__annotations__ = {}