-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When use with Django Components, changes to the .py files do not update until server restart #224
Comments
Are you saying that without Django-browser-reload, the server does restart? And that with Django-browser-reload, it does? |
Without Django-browser-reload, With Django-browser-reload, |
We encountered the same issue. django-components stores Python files along with their media files and HTML templates. It uses django_components.template_loader.Loader, which extends the template directory list to include the parent directories of the Python components. Ref: https://github.com/EmilStenstrom/django-components#installation The "django-browser-reload" app prevents the server from being reloaded when there are changes in the component Python files, as it considers them either template files or static assets. If we agree that Python files are specific enough to require server-side reloading, regardless of their location, the fix should be quite straightforward. I am ready to create a pull request. As a further development of this idea, we can configure the list of extensions that always require a reload via settings. However, I am not sure what else, besides Python, should be included there. |
A list of extensions, or extensions at a path, would be a great solution. This would allow current functionality to be unaltered while allowing a developer to customize as needed. |
Force server reload when Python files are changed even if they are in templates or static directories. Fixes adamchainz#224
I've created a PR #229 to address the issue, and I took the liberty of hardcoding the Python extension as the one that forces the development server to reload regardless. I decided not to parameterize it because I felt like it was such a rare case that adding a settings option for it and documenting it would be more confusing than helpful. It would be a separate but puzzling challenge -- how would we name that settings option if we decided to introduce it? 🤷 However, I am open to feedback. I would especially love to hear @adamchainz's input. Thank you! |
I applied the patch in #229 locally and it worked great! Thank you so much! |
Python Version
3.9.18
Django Version
4.2.7
Package Version
No response
Browser
No response
Description
When used with Django Components you have to restart the server every time you update the
.py
file that registers the component.If you disable Django Browser Reload then the component functionality works as expected.
I created a sample repo with a project demonstrating the issue. Directions are in the project readme.
https://github.com/ayoung-burnsmcd/components-browser-reload
The text was updated successfully, but these errors were encountered: