tomdyson / wagalytics

A Google Analytics dashboard in your Wagtail admin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting request.site.hostname

benmayocode opened this issue · comments

I'm throwing an error when I try to get the host from request.site.hostname in views.py.

I raised it on StackOverflow https://stackoverflow.com/questions/62331479/attributeerror-wsgirequest-object-has-no-attribute-site-wagtail-wagalyti/62332010#62332010, and learnt that request.site is deprecated.

I got out of my depth with this a while back. My understanding from the SO question is I'd need the wagalytics library to be updated to use it without modification.

I'm using wagtail 2.9

Cheers!

commented

Wagtail 2.9 deprecates wagtail.core.middleware.SiteMiddleware which makes the current site object available in request.site.

References to request.site in your code should be removed; the recommended way of retrieving the current site is Site.find_for_request(request)
Source: Wagtail 2.9 Docs

There are 3 references to request.site in views.py that will need to be updated before the middleware can be removed.

Tell me about this issue. Story of my life right now.