C:\Users\andy>Django-admin startproject sundyblog ## 创建项目 C:\Users\andy>cd sundyblog2、C:
C:\Users\andy>Django-admin startproject sundyblog ## 创建项目
C:\Users\andy>cd sundyblog
2、C:\Users\andy\sundyblog>python manage.py startapp blog ##创建模块
3、编程 (编辑 views.py 与 urls.py)
4、C:\Users\andy\sundyblog>Python manage.py migrate ##生成sqlite数据库
5、C:\Users\andy\sundyblog>python manage.py runserver ## 启动服务
过程效果图:
views.py: ## 地址访问返回结果
from djanGo.shortcuts import render
from django.Http import HttpResponse
# Create your views here.
def hello(request):
return HttpResponse('<h2>Hello Sundy</h2>')
urls.py: ## url 绑定返回结果
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
# Examples:
# url(r'^$', 'sundyblog.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^blog/$','blog.views.hello'),
url(r'^admin/', include(admin.site.urls)),
]
访问效果图:
浏览器输入 http://localhost:8000/blog/
--结束END--
本文标题: Django之 HelloWorld
本文链接: https://lsjlt.com/news/244991.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0