Skip to main content

FileSystemFinder

A static files finder that uses the STATICFILES_DIRS setting to locate files.

Attributes

AttributeTypeDescription
locationslistList of locations with static files
storagesdictMaps dir paths to an appropriate storage instance

Constructor

Signature

def FileSystemFinder(
app_names: list = None,
*args: tuple,
**kwargs: dict
) - > null

Parameters

NameTypeDescription
app_nameslist = NoneAn optional list of application names.
*argstupleVariable length argument list passed to the base class constructor.
**kwargsdictArbitrary keyword arguments passed to the base class constructor.

Signature

def FileSystemFinder(
app_names: list = None
) - > null

Parameters

NameTypeDescription
app_nameslist = NoneAn optional list of application names to restrict the search scope.

Methods


check()

@classmethod
def check(
kwargs: dict
) - > list

Validates the STATICFILES_DIRS setting for configuration errors, such as incorrect data types, trailing slashes in prefixes, or overlaps with STATIC_ROOT.

Parameters

NameTypeDescription
kwargsdictAdditional keyword arguments passed to the system check framework.

Returns

TypeDescription
listA list of Error and Warning objects representing configuration issues found in settings.

find()

@classmethod
def find(
path: string,
find_all: boolean = False
) - > string | list

Look for files in the extra locations as defined in STATICFILES_DIRS.

Parameters

NameTypeDescription
pathstringThe relative path of the static file to locate.
find_allboolean = FalseDetermines whether to return the first match found or a list of all matches across all locations.

Returns

TypeDescription
`stringlist`

find_location()

@classmethod
def find_location(
root: string,
path: string,
prefix: string = None
) - > string | null

Find a requested static file in a location and return the found absolute path (or None if no match).

Parameters

NameTypeDescription
rootstringThe directory path to search within.
pathstringThe relative path of the file being searched for.
prefixstring = NoneAn optional URL prefix that the path must start with to be considered a match for this location.

Returns

TypeDescription
`stringnull`

list()

@classmethod
def list(
ignore_patterns: list
) - > generator

List all files in all locations.

Parameters

NameTypeDescription
ignore_patternslistA list of glob patterns used to exclude specific files or directories from the results.

Returns

TypeDescription
generatorA generator yielding tuples of (path, storage) for every file found in the configured locations.