mirror of
https://github.com/django-components/django-components.git
synced 2025-09-17 03:15:02 +00:00
parent
997ed52bb6
commit
dc9f1b46b2
10 changed files with 106 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
|||
import difflib
|
||||
import inspect
|
||||
from collections import ChainMap
|
||||
from typing import Any, ClassVar, Dict, Iterable, Optional, Set, Tuple, Union
|
||||
|
||||
|
@ -87,10 +88,8 @@ class Component(View, metaclass=SimplifiedInterfaceMediaDefiningClass):
|
|||
self.outer_context: Context = outer_context or Context()
|
||||
self.fill_content = fill_content
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def class_hash(cls):
|
||||
return hash(str(cls.__module__) + str(cls.__name__))
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
cls.class_hash = hash(inspect.getfile(cls) + cls.__name__)
|
||||
|
||||
def get_context_data(self, *args, **kwargs) -> Dict[str, Any]:
|
||||
return {}
|
||||
|
|
|
@ -12,17 +12,17 @@ from django.template.utils import get_app_template_dirs
|
|||
class Loader(FilesystemLoader):
|
||||
def get_dirs(self):
|
||||
component_dir = "components"
|
||||
directories = list(get_app_template_dirs(component_dir))
|
||||
directories = set(get_app_template_dirs(component_dir))
|
||||
|
||||
if settings.SETTINGS_MODULE:
|
||||
settings_path = Path(*settings.SETTINGS_MODULE.split("."))
|
||||
|
||||
path = (settings_path / ".." / component_dir).resolve()
|
||||
if path.is_dir():
|
||||
directories.append(path)
|
||||
directories.add(path)
|
||||
|
||||
path = (settings_path / ".." / ".." / component_dir).resolve()
|
||||
if path.is_dir():
|
||||
directories.append(path)
|
||||
directories.add(path)
|
||||
|
||||
return directories
|
||||
return list(directories)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue