Django manage.py runserver不显示“欢迎页面”

时间:2016-08-12 19:35:46

标签: python django django-admin django-manage.py

我正在关注Django教程但是在尝试加载欢迎页面时遇到错误,刚启动服务器后我在其他电脑上完成了本教程,我没有遇到任何问题。

使用:  Windows 7 / Djando 1.9 / Python 3.4.5

1 - 我开始了这个项目 2 - python manage.py runserver enter image description here

3 - 当我访问该页面时:

enter image description here

4 - 我上了cmd

enter image description here

我已经尝试了数百个端口,ips,防火墙禁用,django 1.10 ......

5 - urls.py

from django.conf.urls import include, url
from django.contrib import admin

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

2 个答案:

答案 0 :(得分:1)

问题是您忘记了迁移然后迁移。

py manage.py makemigration

py manage.py migrate

答案 1 :(得分:0)

问题是,您没有为“/”定义路由器或视图。所有有效路径均为http://127.0.0.1/polls/ *和http://127.0.0.1/admin/ *。

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    # load urls of an app and define there more detailed
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
    # load specific view in an app
    url(r'^your_test_view','my_app.views.my_view', name="my_view"),
    url(r'^$','my_app.views.my_home_view', name="home"),
]