PyCharm not reloading automatically for Django server

已回答

This is a weird two-fold bug that's affecting not just me, but other people in my organisation randomly.  Any help would be appreciated by all of us. 

Usually, on the default settings (no-reload is not enabled), PyCharm will detect changes made to a file and reload the Django dev server.  However, we're not getting that.  Interestingly, when that bug manifests itself, reloading the server manually often (but not always) comes with the error that the server is already running on that port and so the server can't be started.  At that point, we need to kill the process manually.  As you can imagine, that's really annoying.

We're not sure what causes any of this or how they're related.  Updating the latest version of PyCharm Professional 2017 fixed the problem for me for two weeks, before it started again.  One of my colleagues has been running 2017 for many months, avoided the problem for a long time and has since been affected by it worse than all of us. 

As I mentioned, any help would be really appreciated. 

2
正式评论

Hello. PyCharm does not reload server: it is done by Django itself.

https://docs.djangoproject.com/en/2.0/ref/django-admin/#runserver

"The development server automatically reloads Python code for each request, as needed. You don’t need to restart the server for code changes to take effect. However, some actions like adding files don’t trigger a restart, so you’ll have to restart the server in these cases.

If you are using Linux and install pyinotify, kernel signals will be used to autoreload the server (rather than polling file modification timestamps each second). This offers better scaling to large projects, reduction in response time to code modification, more robust change detection, and battery usage reduction."

Avatar
Permanently deleted user

Thank you very much!  You're right.  Installing pyionotify has really helped.  I thank you as does my whole team.  And, thanks to your comments, we have a direction to go in looking for a proper solution. 

0

Seconded.  This is very helpful, thank you!  

0

请先登录再写评论。