Django get client's domain name/host name
问题 What is the easiest way to obtain the user's host/domain name, if available? Or is there a function to lookup the IP address of the user to see if it is bound to a named address? (i.e. gethostbyaddr() in PHP) HttpRequest.get_host() only returns the IP address of the user. 回答1: You can't rely on it, but you can try the request.META['REMOTE_HOST'] or request.META['HTTP_HOST'] from the META dictionary of the request : A standard Python dictionary containing all available HTTP headers. Available