小编Tro*_*han的帖子

有没有办法强制 django 在退出之前运行一些整理代码?

我正在使用 django 运行服务器程序,我想在服务器运行之前和之后运行一些代码。我可以把这些代码放在哪里?

<run function a here>
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
^C
<run function b here>
Run Code Online (Sandbox Code Playgroud)

我尝试过print('hello')in app/__init__.py,但发现它运行了两次。为什么?

django python-3.x

6
推荐指数
1
解决办法
2040
查看次数

标签 统计

django ×1

python-3.x ×1