我已经在 pythonanywhere.com 上部署了我的网站,现在我想在某些页面上配置子域,我想知道使用django-subdomains包我做错了什么?
这是我的代码的样子:
设置.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')),
] ...
页面/网址:
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/...
,为什么不存在?我应该为我的 pythonanywhere 服务器设置 DNS 吗?