Django manage.py runserver 不显示 "Welcome Page"
Django manage.py runserver do not display "Welcome Page"
我正在学习 Django 教程,但在尝试加载欢迎页面时出现错误,就在启动服务器后,我在其他电脑上完成了本教程,但我没有遇到任何问题。
使用:
Windows 7 / Djando 1.9 / Python 3.4.5
1 - 我开始了这个项目
2 - python manage.py 运行服务器
3 - 当我访问页面时:
4 - 我进入了 cmd
我已经尝试了数百个端口、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),
]
问题是,您没有为“/”定义路由器或视图。所有有效路径都是 http://127.0.0.1/polls/* and 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"),
]
问题是你忘记了 makemigrations 然后再迁移。
py manage.py makemigration
py manage.py 迁移
我正在学习 Django 教程,但在尝试加载欢迎页面时出现错误,就在启动服务器后,我在其他电脑上完成了本教程,但我没有遇到任何问题。
使用: Windows 7 / Djando 1.9 / Python 3.4.5
1 - 我开始了这个项目
2 - python manage.py 运行服务器
3 - 当我访问页面时:
4 - 我进入了 cmd
我已经尝试了数百个端口、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),
]
问题是,您没有为“/”定义路由器或视图。所有有效路径都是 http://127.0.0.1/polls/* and 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"),
]
问题是你忘记了 makemigrations 然后再迁移。
py manage.py makemigration
py manage.py 迁移