累了的时候看看这个 |
今天尝试使用django开发,但是第一个项目就出错了,信心瞬间跌落低谷啊!求大神帮忙解决,以下是代码和报错页面
项目列表:
创建了一个guess的项目,app为sign
guess.urls代码:
from django.conf.urls import url
from django.contrib import admin
from sign import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$',views.index),
]
sign.views代码:
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse('Hello world!')
guess.setting代码:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'sign',
]
服务器报错:
C:\Users\Administrator\guess>python manage.py runserver 127.0.0.1:8000
Performing system checks...
System check identified no issues (0 silenced).
You have 1 unapplied migration(s). Your project may not work properly until you
apply the migrations for app(s): auth.
Run 'python manage.py migrate' to apply them.
May 04, 2017 - 17:16:40
Django version 1.11, using settings 'guess.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[04/May/2017 17:16:54] "GET / HTTP/1.1" 200 1716
Not Found: /index
[04/May/2017 17:17:05] "GET /index HTTP/1.1" 404 1943
页面报错:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/index
Using the URLconf defined in guess.urls, Django tried these URL patterns, in this order:
^admin/
The current path, index, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
过早客微信公众号:guozaoke • 过早客新浪微博:@过早客 • 广告投放合作微信:fullygroup50 鄂ICP备2021016276号-2 • 鄂公网安备42018502001446号