1

我正在调试一个运行得非常愉快的 Django 应用程序,python manage.py runserver ...但在使用 Python 3.4 的 uWSGI 下运行时却没有。我发现我的 Unipath 选择器在 manage.py 环境中运行良好,但在 uWSGI 下运行时会产生错误的结果。这些会导致各种困难和奇怪的信息。

所以我的设置文件中的调试代码是:

print("Hi from settings/base.py file = {}, cleaned up ={}".format(__file__,str(Path(__file__))))

在 manage.py 我得到:

Hi from settings/base.py file = /home/ubuntu/projects/myproj/myproj/myproj/settings/base.py, cleaned up = /home/ubuntu/projects/myproj/myproj/myproj/settings/base.py

并使用 uwsgi 运行我得到:

Hi from settings/base.py file = ./myproj/settings/base.py, cleaned up = ./myproj/settings/base.py

我期待 URL 被规范化。

4

1 回答 1

1

尝试先调用absolute(),如下所示:

print('Hi from settings/base.py file = {}, cleaned up  {}'.format(
    __file__,
    str(Path(__file__).absolute()),
))
于 2014-06-10T09:16:50.440 回答