当我不使用“127.0.0.1:8000"

时间:2017-06-04 20:56:32

标签: python django wagtail

我已将以下内容添加到我的settings.py

ALLOWED_HOSTS = ['0.0.0.0','127.0.0.1','192.168.0.05']

我的url.py

urlpatterns = [
url(r'^django-admin/', include(admin.site.urls)),

url(r'^admin/', include(wagtailadmin_urls)),
url(r'^documents/', include(wagtaildocs_urls)),

#url(r'^search/$', search_views.search, name='search'),

# For anything not caught by a more specific rule above, hand over to
# Wagtail's page serving mechanism. This should be the last pattern in
# the list:
#url(r'', include(wagtail_urls)),

# Alternatively, if you want Wagtail pages to be served from a subpath
# of your site, rather than the site root:
#    url(r'^pages/', renders(wagtail_urls)),
url(r'^i18n/', include('django.conf.urls.i18n')),

]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

urlpatterns += i18n_patterns(
# These URLs will have /<language_code>/ appended to the beginning
url(r'^search/$', search_views.search, name='search'),
url(r'', include(wagtail_urls)),
#url(r'^$', include(wagtail_urls)),
 )

困境就是当我做“http://127.0.0.1:8000/en”时,它工作得很好但是当我从同一个局域网的手机上做“http://192.168.0.5:8000/en/”时,甚至是我在托管的笔记本电脑上“找不到页面(404)”。

导致此类行为的原因是我在url.py中忽略了某些内容。

我尝试按如下方式运行它:

python manage.py runserver 192.168.0.13:8000
python manage.py runserver 0.0.0.0:8000

其中没有帮助。

我知道它不是防火墙问题,因为未找到的页面是django服务响应的结果。

1 个答案:

答案 0 :(得分:2)

检查设置下的网站记录 - &gt; Wagtail管理员中的网站。当请求进入时,如果主机名与站点记录中指定的主机名匹配,则Wagtail将仅提供页面,或者选中“是默认站点”框。