mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 03:31:04 +01:00
Update wording
Also move warning so it occurs on server startup rather than first request
This commit is contained in:
parent
7b6a89c155
commit
96cd5c066d
@ -40,7 +40,7 @@ Middleware (``settings.py``)
|
||||
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
|
||||
]
|
||||
|
||||
Wagtail requires several common Django middleware modules to work and cover basic security. Wagtail provides its own middleware to cover these tasks:
|
||||
Wagtail depends on the default set of Django middleware modules, to cover basic security and functionality such as login sessions. One additional middleware module is provided:
|
||||
|
||||
``RedirectMiddleware``
|
||||
Wagtail provides a simple interface for adding arbitrary redirects to your site and this module makes it happen.
|
||||
|
@ -5,18 +5,20 @@ from wagtail.core.models import Site
|
||||
from wagtail.utils.deprecation import RemovedInWagtail211Warning
|
||||
|
||||
|
||||
warnings.warn(
|
||||
'wagtail.core.middleware.SiteMiddleware and the use of request.site is deprecated. '
|
||||
'Please update your code to use Site.get_for_request(request) in place of request.site, '
|
||||
'and remove wagtail.core.middleware.SiteMiddleware from MIDDLEWARES',
|
||||
RemovedInWagtail211Warning
|
||||
)
|
||||
|
||||
|
||||
class SiteMiddleware(MiddlewareMixin):
|
||||
def process_request(self, request):
|
||||
"""
|
||||
Set request.site to contain the Site object responsible for handling this request,
|
||||
according to hostname matching rules
|
||||
"""
|
||||
warnings.warn(
|
||||
'Wagtail SiteMiddleware and the use of request.site is deprecated '
|
||||
'and will be removed in Wagtail 2.11. Update your middleware settings.',
|
||||
RemovedInWagtail211Warning, stacklevel=2
|
||||
)
|
||||
|
||||
try:
|
||||
request.site = Site.find_for_request(request)
|
||||
except Site.DoesNotExist:
|
||||
|
Loading…
Reference in New Issue
Block a user