A simple method is to omit the SITE_ID setting from the Sites framework. Then include the Sites framework middleware:'django.contrib.sites.middleware.CurrentSiteMiddleware'这会在每次请求时自动将 request 对象传递给 Site.objects.get_current().它还允许您的Django应用程序通过 request.site 检测当前站点.This automatically passes a request object to Site.objects.get_current() on every request. It also allows your Django application to detect the current site via request.site.您需要确保使用NGINX或apache实例设置多个虚拟主机,以将流量从每个站点路由到您的服务器.You would need to make sure to setup multilple virtual hosts using your NGINX or apache instance to route traffic from each site to your server. 这篇关于如何为网站框架django设置多个settings.py?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
05-19 07:32