MCPcopy
hub / github.com/django/django / get_current_site

Function get_current_site

django/contrib/sites/shortcuts.py:6–18  ·  view source on GitHub ↗

Check if contrib.sites is installed and return either the current ``Site`` object or a ``RequestSite`` object based on the request.

(request)

Source from the content-addressed store, hash-verified

4
5
6def get_current_site(request):
7 """
8 Check if contrib.sites is installed and return either the current
9 ``Site`` object or a ``RequestSite`` object based on the request.
10 """
11 # Import is inside the function because its point is to avoid importing the
12 # Site models when django.contrib.sites isn't installed.
13 if apps.is_installed("django.contrib.sites"):
14 from .models import Site
15
16 return Site.objects.get_current(request)
17 else:
18 return RequestSite(request)

Callers 15

saveMethod · 0.90
get_context_dataMethod · 0.90
get_context_dataMethod · 0.90
flatpageFunction · 0.90
renderMethod · 0.90
indexFunction · 0.90
sitemapFunction · 0.90
process_responseMethod · 0.90
get_feedMethod · 0.90
shortcutFunction · 0.90
test_get_current_siteMethod · 0.90

Calls 3

RequestSiteClass · 0.85
is_installedMethod · 0.80
get_currentMethod · 0.80