1、C:\Users\andy>django-admin startproject sundyblog ## 創(chuàng)建項目
C:\Users\andy>cd sundyblog
2、C:\Users\andy\sundyblog>python manage.py startapp blog ##創(chuàng)建模塊
3、編程 (編輯 views.py 與 urls.py)
4、C:\Users\andy\sundyblog>python manage.py migrate ##生成sqlite數(shù)據(jù)庫
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('
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/