AppDirectoriesFinder
A static files finder that looks in the directory of each app as specified in the source_dir attribute.
Attributes
| Attribute | Type | Description |
|---|---|---|
| storage_class | class = FileSystemStorage | The storage class used to instantiate storage instances for each discovered application directory. |
| source_dir | string = "static" | The name of the subdirectory within each app where the finder looks for static files. |
Constructor
Signature
def AppDirectoriesFinder(
app_names: list|set|null = None,
*args: any,
**kwargs: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| app_names | `list | set |
| *args | any | Variable length argument list passed to the parent class constructor. |
| **kwargs | any | Arbitrary keyword arguments passed to the parent class constructor. |
Signature
def AppDirectoriesFinder(
app_names: list = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| app_names | list = None | An optional list of specific application names to restrict the search to; if None, all installed apps are used. |
Methods
list()
@classmethod
def list(
ignore_patterns: list
) - > generator
List all files in all app storages.
Parameters
| Name | Type | Description |
|---|---|---|
| ignore_patterns | list | A list of glob patterns used to exclude specific files or directories from the resulting list. |
Returns
| Type | Description |
|---|---|
generator | A generator yielding tuples of the relative file path and the storage instance where the file was found. |
find()
@classmethod
def find(
path: string,
find_all: boolean = False
) - > string|list
Look for files in the app directories.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | The relative path of the static file to locate within the app directories. |
| find_all | boolean = False | A flag determining whether to return the first match found or a list of all matches across all apps. |
Returns
| Type | Description |
|---|---|
| `string | list` |
find_in_app()
@classmethod
def find_in_app(
app: string,
path: string
) - > string|null
Find a requested static file in an app's static locations.
Parameters
| Name | Type | Description |
|---|---|---|
| app | string | The name of the application to search within. |
| path | string | The relative path of the file to look for in the app's static storage. |
Returns
| Type | Description |
|---|---|
| `string | null` |