Handle case with SETTINGS_MODULE not set.

This commit is contained in:
Emil Stenström 2022-07-18 09:23:04 +02:00
parent 681c540cb7
commit f5c3f64c86

View file

@ -13,14 +13,16 @@ class Loader(FilesystemLoader):
def get_dirs(self):
component_dir = "components"
directories = list(get_app_template_dirs(component_dir))
settings_path = Path(*settings.SETTINGS_MODULE.split("."))
path = (settings_path / ".." / component_dir).resolve()
if path.is_dir():
directories.append(path)
if settings.SETTINGS_MODULE:
settings_path = Path(*settings.SETTINGS_MODULE.split("."))
path = (settings_path / ".." / ".." / component_dir).resolve()
if path.is_dir():
directories.append(path)
path = (settings_path / ".." / component_dir).resolve()
if path.is_dir():
directories.append(path)
path = (settings_path / ".." / ".." / component_dir).resolve()
if path.is_dir():
directories.append(path)
return directories