Can't find relative component template #425
-
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
But if I add the component path in my |
Beta Was this translation helpful? Give feedback.
-
@JuroOravec Mind having a look? |
Beta Was this translation helpful? Give feedback.
-
Hey both, I'm having a look now. |
Beta Was this translation helpful? Give feedback.
-
Also, don't know if it will be related or not, but in our project we have a weird problem with the relative imports - things work locally, and in prod. BUT, there is a single JS file that does not get recognized by the django-component's path resolution logic. |
Beta Was this translation helpful? Give feedback.
-
Ok, so I've copied the repo and run the project (see the commands below). After I've changed the gh repo clone EmilStenstrom/django-components
cd django-components/sampleproject
mkdir .venv
pipenv install
python manage.py migrate && python manage.py runserver 0.0.0.0:8000
curl localhost:8000
curl localhost:8000/greeting/
curl localhost:8000/calendar/ What I noticed is that using the I got a suggestion from ChatGPT to use following method to derive the component's file path from component class: import sys
module_name = attrs["__module__"]
module_obj = sys.modules[module_name]
file_path = module_obj.__file__
print("FILE_PATH: ", file_path)
# FILE_PATH: /Users/presenter/repos/django-components2/django-components/sampleproject/components/calendar/calendar.py I'll poke a bit more around and see if using this approach would solve the bugs we're seeing. |
Beta Was this translation helpful? Give feedback.
-
@khasbilegt We've released v0.65 that should fix this issue for you. For now I'll mark this as answered, but do give it a test yourself and let us know :) |
Beta Was this translation helpful? Give feedback.
@khasbilegt We've released v0.65 that should fix this issue for you. For now I'll mark this as answered, but do give it a test yourself and let us know :)