how do i get the hostname of a django application

时间:2022-01-14 07:33:46

I have a django application running using gunicorn and frontended by nginx. I am trying to get the full hostname of the application because I need to redirect out of the application and need to pass the external application my url so it can pass control back to me. How do I find my hostname/application name. I tried request.get_host(), but it gave me 127.0.0.1:8000

我有一个django应用程序运行使用gunicorn和nginx前缀。我试图获取应用程序的完整主机名,因为我需要重定向到应用程序,并需要传递外部应用程序我的URL,以便它可以将控制权传递给我。如何查找主机名/应用程序名称。我试过request.get_host(),但它给了我127.0.0.1:8000

1 个解决方案

#1


0  

You can access it from the request object's META attribute.

您可以从请求对象的META属性访问它。

request.META['HTTP_HOST']

#1


0  

You can access it from the request object's META attribute.

您可以从请求对象的META属性访问它。

request.META['HTTP_HOST']