Django服务器不重新加载文件更改

发布于 2025-01-31 07:12:48 字数 664 浏览 1 评论 0原文

我只是从Github克隆了一个Django项目,以在另一台计算机上进行维护,安装了所有依赖项,然后运行了服务器。除了在所有Python文件上进行文件更改时,服务器不会重新加载,一切似乎都可以正常工作。静态文件的更改也不会反映。要注意的事情:

  • Django 4.0.3
  • Python 3.9.0
  • 环境经理是Pipenv。

settings.py

DEBUG = True

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, "templates")],

我没有自定义runserver命令
我对此有建议问题,但它们没有起作用。

任何帮助将不胜感激。

I just cloned a Django project from my Github for maintenance on another machine, installed all the dependencies then ran the server. Everything seems to be working fine except the fact that the server does not reload when I make file changes (on all python files). Changes in static files are not reflected too. Things to note:

  • Django 4.0.3
  • Python 3.9.0
  • Environment manager is Pipenv.

Settings.py

DEBUG = True

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, "templates")],

I don't have a custom runserver command
I have the suggestions on this question but they didn't work.

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剩一世无双 2025-02-07 07:12:48

要重新加载浏览器中的所有静态文件,您需要按ctrl + f5(刷新高速缓存)

,请确保运行python manage.py collect.pocletstatic命令以保存所有静态单个目录中的文件,甚至使用压缩存储。

对于所有Python文件,请确保在Visual Studio代码上启用AutoSave(我也遇到了此问题)

To reload all static files in the browser you need to press ctrl + f5 (refreshes cache)

Also, make sure to run the python manage.py collectstatic command to save all static files in a single directory or even use compressed storage.

For all python files, make sure that autosave is enabled on Visual Studio Code (I have faced this issue too)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文