过早客
  • 首页
  • 节点
  • 成员
  • 广告投放
  • 登录
  • 注册

django第一个项目报错,求大神帮助

IT技术 • zx_le_python • 发表于 8 年前 • 最后回复来自 zx_le_python • 8 年前

今天尝试使用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

Create your views here.

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.

加入收藏 新浪微博 分享到微信 ❤赞 17312 次点击 0 人赞 0 人收藏

打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮

共收到5条回复
swift 8 年前 #1 赞 0

都没运行起来,查查是不是权限或者目录的问题

cygnushan 8 年前 #2 赞 0

没有/index的路由

xiaowuge 8 年前 #3 赞 0

没有问题啊 只是你没写/index的路由和处理函数

zlinghu 8 年前 #4 赞 0

url配置里面第二个写错了,^index$才对,或者你不改url配置直接访问127.0.0.1:8000就可以了

zx_le_python 楼主 8 年前 #5 赞 0

@zlinghu 直接访问127.0.0.1:8000是正常的,但是访问index页面就报这个错,url按照^index$配置一样是报这个错

请绑定手机号后,再发言,点击此处
Guozaoke.com—源自武汉的高端交流分享社区
相关主题
iOS 过早客没有数据,大佬们求教!
GPT-5
寻有K12教育行业软件开发经验的同学合作
你们都用哪些AI工具,求分享下~
过早客flutter版来了
亲测,鸿蒙开发奖励到手了
感觉gemini已经是一骑绝尘
分享一个拥有很多好看壁纸的插件
作为后端开发工程师,你们有中途转向机器学习/深度学习的吗?
写了个过早客的暗色插件,个人感觉很好用嘿嘿

过早客微信公众号:guozaoke • 过早客新浪微博:@过早客 • 广告投放合作微信:fullygroup50 鄂ICP备2021016276号-2 • 鄂公网安备42018502001446号