我已经在pythonanywhere.com上部署了我的网站,现在我想在某些网页上配置子域名,我想知道我使用django-subdomains软件包做错了什么?< / p>
以下是我的代码:
settings.py:
... (already installed 'subdomains' in INSTALLED_APPS)
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'subdomains.middleware.SubdomainURLRoutingMiddleware', #before CommonMiddleware
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'site.urls'
SUBDOMAIN_URLCONFS = {
None: 'site.urls',
'www': 'site.urls',
'web': 'pages.urls.web',
'account': 'site.urls.login',
}
SITE_ID = 1
...
网站/网址:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^accounts/login/$', auth_views.login, name='login'),
url(r'^', include('pages.urls')),
url(r'^accounts/', include('utilisateur.urls')),
] ...
pages / urls:
urlpatterns = [
...
url(r'^$', views.index, name="index"),
url(r'^web/$', views.web, name="web"),
...
]
当我输入web.site.ch/web/
时,找不到地址。 www.site.ch/web/
仍然存在web.site.ch/web/
,accounts.site.ch/...
相同,为什么不是?{1}}我应该在我的pythonanywhere服务器上设置DNS吗?
答案 0 :(得分:1)
要获取Web请求以进入Web应用程序,您需要做两件事:
django-subdomains不执行其中任何一项。