Is it possible to use the Django Sites Framework with multiple Sites on the same instance?

余生长醉 提交于 2019-12-06 05:28:31

To "check the current domain" you need to have a request - as clearly mentionned in the error message :

or pass a request to Site.objects.get_current()

Else how would the code know the "current domain" ?

The best solution is to simply add the Sites framework middleware:

'django.contrib.sites.middleware.CurrentSiteMiddleware'

This automatically passes a request object to Site.objects.get_current() on every request.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!