1.安装好Python 2.7.10
2.下载解压Django Django-1.9.2.tar.gz
cmd cd到解压缩目录(***)
python setup.py install
3.检测是否安装成功
import django
django.Version
print (django.__path__) 双下划线
P.S.环境变量
path:
C:\Python27\Lib\site-packages\Django-1.9.2-py2.7.egg\django\bin;
C:\Python27\Scripts
4.新建工程
django-admin.py startproject mysite
dir /b查看
5.启动服务器
先cd到mysite下
manage.py runserver
6.web打开
127.0.0.1:8000
查看端口占用netstat –ano
kill掉进程
纠错:manage.py runserver 8080~~~麻蛋
相关参考资料
http://www.oschina.net/question/234345_54799
http://www.ibm.com/developerworks/cn/linux/l-django/
Hello World
页面的内容是靠view function(视图函数) 来产生,URL定义在 URLconf 中
1.新建Project
django-admin.py startproject mysite
2.新建APP,于manage.py一个目录
manage.py startapp polls
3.新建View函数
路径:polls/view.py
from django.shortcuts import render # Create your views here. from django.http import HttpResponse def index(request):
return HttpResponse("HelloWorld")
4.新建URLconf
polls/urls.py
from django.conf.urls import url from . import views urlpatterns=[
url(r'^$',views.index,name='index'),]
链接到root URLconf
from django.conf.urls import include,url
from django.contrib import admin urlpatterns = [
url(r'^polls/',include('polls.urls')),
url(r'^admin/', admin.site.urls),
]
To call the view, we need to map it to a URL
结果:
遇到的问题: