Skip to content
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

Restart Django development server on Python file changes #229

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

imankulov
Copy link

Force server reload when Python files are changed even if they are in
templates or static directories.

Fixes #224

Force server reload when Python files are changed even if they are in
templates or static directories.

Fixes adamchainz#224
@imankulov
Copy link
Author

Hey @adamchainz, could you please take a look at it and give your feedback whenever you have some time? Thanks a lot!

@ayoung-burnsmcd
Copy link

@imankulov @adamchainz I applied this patch locally and it worked great!

Thank you so much!

@ayoung-burnsmcd
Copy link

Good afternoon. Is there anything additoinal that needs to be done before this can be merged?

@jesserankin
Copy link

I tried out this change with django-components, and it worked great for triggering the runserver reload. A problem I ran into was that the change triggers both the runserver and the browser refresh in the on_file_changed function. I believe the browser refresh is unnecessary because restarting the runserver already triggers a browser refresh. When I tested the change, sometimes the first refresh would happen before the runserver had fully restarted, and so I would get an 'unable to connect' error page. I changed the on_file_changed function to either trigger a runserver reload for .py files or a browser refresh for everything else, and now everything is working smoothly for me.

@ayoung-burnsmcd
Copy link

@jesserankin can you share your updates?

@jesserankin
Copy link

Sure, you can see my changes here:

jesserankin@f7d3d93

This was just a quick change I made to fix the issue I was having, but isn't polished. I'm happy to do some more work on it if it would help this PR to get merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When use with Django Components, changes to the .py files do not update until server restart
3 participants