Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/django/contrib/sites/shortcuts.py: 22%
7 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1from django.apps import apps
4def get_current_site(request):
5 """
6 Check if contrib.sites is installed and return either the current
7 ``Site`` object or a ``RequestSite`` object based on the request.
8 """
9 # Imports are inside the function because its point is to avoid importing
10 # the Site models when django.contrib.sites isn't installed.
11 if apps.is_installed("django.contrib.sites"):
12 from .models import Site
14 return Site.objects.get_current(request)
15 else:
16 from .requests import RequestSite
18 return RequestSite(request)