败扯了,就是看遍http://djangobook.py3k.cn/
>>> import django
>>> django.VERSION
django-admin.py 放到path下
django-admin.py startproject mysite
python manage.py runserver 192.168.76.128:8000
views.py post提交
from django.http import HttpResponse import datetime def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.<form method='post' action='/test'><input type='text' name='test'/><input type='submit' /></form</body></html>" % now return HttpResponse(html) def test(request): #html="test %s" % request.get_full_path(); #html="test %s" % request.get_host(); html="this post is %s,request.get_full_path(): %s,request.get_host(): %s" % (request.POST['test'],request.get_full_path(),request.get_host()); # html="test %s" % request.POST['test']; return HttpResponse(html);
from django.conf.urls.defaults import * from mysite.views import current_datetime,test urlpatterns = patterns('', (r'^time', current_datetime), (r'^test', test), )
在settings.py里的MIDDLEWARE_CLASSES中加入下面两行: 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfResponseMiddleware', 不加则post提交报403
----------
python manage.py shell