mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
Fix for #290
This commit is contained in:
parent
87cf485a5d
commit
567c8ccc3d
9 changed files with 129 additions and 8 deletions
|
@ -14,15 +14,23 @@ class Loader(FilesystemLoader):
|
|||
component_dir = "components"
|
||||
directories = set(get_app_template_dirs(component_dir))
|
||||
|
||||
if hasattr(settings, "BASE_DIR"):
|
||||
path = (settings.BASE_DIR / component_dir).resolve()
|
||||
if path.is_dir():
|
||||
directories.add(path)
|
||||
|
||||
if settings.SETTINGS_MODULE:
|
||||
settings_path = Path(*settings.SETTINGS_MODULE.split("."))
|
||||
module_parts = settings.SETTINGS_MODULE.split(".")
|
||||
module_path = Path(*module_parts)
|
||||
|
||||
path = (settings_path / ".." / component_dir).resolve()
|
||||
if path.is_dir():
|
||||
directories.add(path)
|
||||
if len(module_parts) > 2:
|
||||
module_path = Path(*module_parts[:-1])
|
||||
|
||||
path = (settings_path / ".." / ".." / component_dir).resolve()
|
||||
if path.is_dir():
|
||||
directories.add(path)
|
||||
# Use list() for < Python 3.9
|
||||
for parent in list(module_path.parents)[:2]:
|
||||
print(parent)
|
||||
path = (parent / component_dir).resolve()
|
||||
if path.is_dir():
|
||||
directories.add(path)
|
||||
|
||||
return list(directories)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue