获取 Django 应用程序 运行 Apache WSGI 的根 URL

Get the root URL for a Django aplication running with Apache WSGI

我是 运行 一个在 http://localhost/myApplication 中使用 Apache WSGI 的 Django 应用程序。

如何获得根路径含义:http://localhost/myApplication。从文档中我可以看到请求对象有 get_host() 但是这个 returns localhost 我看不到 return 根路径的任何内容。我不想在设置上使用任何东西,因为如果我更改 WSGI Apache 配置中的路径,那会迫使我更改设置。

非常感谢任何想法

您只能通过访问 request.META['SCRIPT_NAME'] 根据每个请求获取它。因为它仅基于每个请求,所以在 Django 设置文件中没有用。