python - 刷新 django 中的 urls.py 缓存

标签 python django nginx fastcgi

我在 nginx 上使用 djangoFastCGI 并且我遇到了 urls.py 的问题。根据this question ,django 缓存 url.py 文件,而我 - 就像上面问题的作者一样 - 无法修改我的 URL 定义。

我的问题是 - 有没有什么方法可以在不重启服务器的情况下清除 django/nginx/fcgi 中的 url 缓存(无论如何都无济于事)?

最佳答案

这不仅仅是 urls.py 的东西,它是运行 wsgi 或 fastcgi 应用程序的正常工作流程。该模块在内存中,在您告诉服务器它已更改之前,它不会从磁盘重新加载。

根据 Django's FastCGI docs :

If you change any Python code on your site, you'll need to tell FastCGI the code has changed. But there's no need to restart Apache in this case. Rather, just reupload mysite.fcgi, or edit the file, so that the timestamp on the file will change. When Apache sees the file has been updated, it will restart your Django application for you.

If you have access to a command shell on a Unix system, you can accomplish this easily by using the touch command:

touch mysite.fcgi

对于开发,在大多数情况下您可以使用 django development server ,它会监视代码更改并在发现某些更改时重新启动。

关于python - 刷新 django 中的 urls.py 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9671924/

相关文章:

python - 如何在 python 中获取 selenium chrome web 驱动程序中的状态代码

python - 在 Django 中使用 Celery 设置结果后端 (rpc)

django在保存文章时不添加自动递增主键id

python - 如何使用 Django 模型中的函数迭代 SQL 数据库?

nginx - Cloud Run 中的 API 和虚拟机中的 Nginx 反向代理

django - 我到底如何使用 nginx 和 Gunicorn 为 Django 应用程序提供静态文件服务器?

nginx - 如何在 nginx 中使用 url 路径名作为上游哈希

python - 这个变量声明在 python 中如何工作?

Python-Application .desktop-shortcut 导致故障

Python 日志记录 - 多个模块