wg-backend-django/dell-env/lib/python3.11/site-packages/django/contrib/sites/shortcuts.py
2023-10-30 14:40:43 +07:00

19 lines
573 B
Python

from django.apps import apps
from .requests import RequestSite
def get_current_site(request):
"""
Check if contrib.sites is installed and return either the current
``Site`` object or a ``RequestSite`` object based on the request.
"""
# Import is inside the function because its point is to avoid importing the
# Site models when django.contrib.sites isn't installed.
if apps.is_installed("django.contrib.sites"):
from .models import Site
return Site.objects.get_current(request)
else:
return RequestSite(request)