sites.shortcuts.get_current_site()

shortcuts.get_current_site(request)

A function that checks if django.contrib.sites is installed and returns either the current Site object or a RequestSite object based on the request. It looks up the current site based on request.get_host() if the SITE_ID setting is not defined.

Both a domain and a port may be returned by request.get_host() when the Host header has a port explicitly specified, e.g. example.com:80. In such cases, if the lookup fails because the host does not match a record in the database, the port is stripped and the lookup is retried with the domain part only. This does not apply to RequestSite which will always use the unmodified host.

Changed in Django 1.9:

Retrying the lookup with the port stripped was added.

doc_Django
2016-10-09 18:39:40
Comments
Leave a Comment

Please login to continue.