mirror of https://github.com/django/django.git
Moved RequestSite import to the toplevel.
This commit is contained in:
parent
05cde4764d
commit
78163d1ac4
|
@ -1,16 +1,17 @@
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
|
||||||
|
from .requests import RequestSite
|
||||||
|
|
||||||
|
|
||||||
def get_current_site(request):
|
def get_current_site(request):
|
||||||
"""
|
"""
|
||||||
Check if contrib.sites is installed and return either the current
|
Check if contrib.sites is installed and return either the current
|
||||||
``Site`` object or a ``RequestSite`` object based on the request.
|
``Site`` object or a ``RequestSite`` object based on the request.
|
||||||
"""
|
"""
|
||||||
# Imports are inside the function because its point is to avoid importing
|
# Import is inside the function because its point is to avoid importing the
|
||||||
# the Site models when django.contrib.sites isn't installed.
|
# Site models when django.contrib.sites isn't installed.
|
||||||
if apps.is_installed('django.contrib.sites'):
|
if apps.is_installed('django.contrib.sites'):
|
||||||
from .models import Site
|
from .models import Site
|
||||||
return Site.objects.get_current(request)
|
return Site.objects.get_current(request)
|
||||||
else:
|
else:
|
||||||
from .requests import RequestSite
|
|
||||||
return RequestSite(request)
|
return RequestSite(request)
|
||||||
|
|
Loading…
Reference in New Issue