FileSystemFinder
A static files finder that uses the STATICFILES_DIRS setting to locate files.
Attributes
| Attribute | Type | Description |
|---|---|---|
| locations | list | List of locations with static files |
| storages | dict | Maps dir paths to an appropriate storage instance |
Constructor
Signature
def FileSystemFinder(
app_names: list = None,
*args: tuple,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| app_names | list = None | An optional list of application names. |
| *args | tuple | Variable length argument list passed to the base class constructor. |
| **kwargs | dict | Arbitrary keyword arguments passed to the base class constructor. |
Signature
def FileSystemFinder(
app_names: list = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| app_names | list = None | An 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
| Name | Type | Description |
|---|---|---|
| kwargs | dict | Additional keyword arguments passed to the system check framework. |
Returns
| Type | Description |
|---|---|
list | A 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
| Name | Type | Description |
|---|---|---|
| path | string | The relative path of the static file to locate. |
| find_all | boolean = False | Determines whether to return the first match found or a list of all matches across all locations. |
Returns
| Type | Description |
|---|---|
| `string | list` |
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
| Name | Type | Description |
|---|---|---|
| root | string | The directory path to search within. |
| path | string | The relative path of the file being searched for. |
| prefix | string = None | An optional URL prefix that the path must start with to be considered a match for this location. |
Returns
| Type | Description |
|---|---|
| `string | null` |
list()
@classmethod
def list(
ignore_patterns: list
) - > generator
List all files in all locations.
Parameters
| Name | Type | Description |
|---|---|---|
| ignore_patterns | list | A list of glob patterns used to exclude specific files or directories from the results. |
Returns
| Type | Description |
|---|---|
generator | A generator yielding tuples of (path, storage) for every file found in the configured locations. |