django - settings.py seems to load multiple times?(django - settings.py 似乎加载了多次?)
问题描述
编辑我记错了 - 它被打印了两次,而不是四次.
EDIT I miscounted - it is printed out twice, not four times.
我把它放在我的 settings.py
print 'ola!'
并且在启动时ola"被打印出来两次!这似乎是我的 pycharm django 项目有问题......有什么想法会发生这种情况吗?它不在循环或任何东西中(无论如何我都知道)
and on startup "ola" is printed out twice! This seems like something is wrong with my pycharm django project ... any ideas why this would happen? It isn't in a loop or anything (that i'm aware of, anyway)
干杯!
YAY 根据评论,仅称为rohit"的用户已确定可以在此处找到解决方案:https://stackoverflow.com/a/2110584/1061426 ~ 查看关于禁用重新加载的评论.
YAY The user known only as "rohit", as per the comments, has determined that a solution can be found here: https://stackoverflow.com/a/2110584/1061426 ~ see the comment about disabling reloading.
注意我现在还没有我的 Django 代码,所以我不知道 noload 会做什么.祝你好运,士兵们.
CAUTION I don't have my Django code up and about now, so I don't know what the noload will do. Good luck, soldiers.
推荐答案
如果你在settings.py中打印出线程ID,你会看到settings.py实际上是在两个不同的线程上加载的.
If you print out the thread ID within settings.py, you will see that settings.py is actually being loaded on two different threads.
请参阅 此 stackoverflow 响应 和 这篇文章了解更多信息.
See this stackoverflow response and this article for more info.
这篇关于django - settings.py 似乎加载了多次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:django - settings.py 似乎加载了多次?


基础教程推荐
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 筛选NumPy数组 2022-01-01