这是一个创建于 3747 天前的主题,其中的信息可能已经有所发展或是发生改变。
也就是用 uwsgi 将django 跑起来后, 首先让 startup code 执行。
比如一个初始化函数,这个初始化函数又需要django.conf.settings 的配置,
所以直接放在 settings.py 不行,
其他地方也试过了, 貌似 python manage.py runserver 可以让startup code execute
但是 用uwsgi跑django 就不行
何解?
3 条回复 • 2014-06-30 17:35:43 +08:00
|
|
1
yueyoum 2014-06-30 17:23:26 +08:00
是我自己 uwsgi 配置的问题
这个配置用了 两三年了 module = django.core.handlers.wsgi:WSGIHandler()
后来按照 django docs 改成
module=mysite.wsgi:application
就好了
|
|
|
2
lambdaq 2014-06-30 17:34:28 +08:00
uwsgi 配置里写 exec-pre-app 或者 import 都可以。
|
|
|
3
yueyoum 2014-06-30 17:35:43 +08:00
然后把 startup code 写到 mysite/ wsgi.py 中就好了
|