简介
Django 是由 Python开发的一个免费的开源网站框架,可以用于快速搭建高性能,优雅的
网站!
win安装
- 下载django 1.9.8,解压
- python setup.py install
- 查看是否安装成功
import django
django.VERSION
django.get_version()
命令
django-admin startproject django1
文档结构图:
python manage.py runserver
或者 python manage.py runserver 8080
Paste_Image.png
python manage.py startapp pools
pools/views.py
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse("Hello World")
pools/urls.py
The url() function is passed four arguments, two required: regex and view, and two optional: kwargs, and name.
from django.conf.urls import url
from . import views
urlpatterns=[
url(r'^$',views.index,name='index'),
]
django1/urls.py
from django.conf.urls import include,url
from django.contrib import admin
urlpatterns = [
url(r'^pools/', include('pools.urls')),
url(r'^admin/', admin.site.urls),
]
测试
http://localhost:8000/pools/
参考
Django 基础教程
官网
官网入门指南
django 1.5API
django 1.5API
django 1.8.2API
csdn-django1.9API
Django 1.9.6 官方文档 第二部分(中文翻译)
网友评论