Source code for django.contrib.sites.shortcuts

fromdjango.appsimportappsdefget_current_site(request):""" Check if contrib.sites is installed and return either the current ``Site`` object or a ``RequestSite`` object based on the request. """# Imports are inside the function because its point is to avoid importing# the Site models when django.contrib.sites isn't installed.ifapps.is_installed('django.contrib.sites'):from.modelsimportSitereturnSite.objects.get_current(request)else:from.requestsimportRequestSitereturnRequestSite(request)