该书 英文原版是 2015年 出版的
web框架:
JavaScript 创建的 Angular.js, Ember.js, Backbone.js之类的面向前端的Web框架,
它们是现代Web开发中的先驱.
很想知道 如何将一个Backbone.js整合到你的Django项目中去.
本书对 不具备编写Python 和 JavaScript程序能力的人来说,这本书可能不适合.
书中的 代码样例是: http://github.com/lightweightdjango/examples
https://www.python.org/downloads/
书中的例子 在 python 3.3 和 python 3.4 中 都得到到了测试.
Django 版本是 1.8.3
使用pip 安装
pip https://github.com/django/django/archive/stable/1.8.x.zip
django 版本的 新的特性:
https://docs.djangoproject.com/en/dev/releases/1.8/
假设读者 具备了 基本的HTML和CSS知识.
JavaScript的知识.
HTTP协议的知识. (GET POST PUT DELETE等)
本书中:
python -V
Python 3.5.2
mkdir lightweightdjango
cd lightweightdjango/
pwd
/home/jack/lightweightdjango
virtualenv -p /usr/bin/python3 venv_py3
source venv_py3/bin/activate
pip install django==1.8.3
mkdir work
cd work/
git clone https://github.com/lightweightdjango/examples.git
git branch -a
git branch
git checkout remotes/origin/chapter-1
python hello.py runserver
http://127.0.0.1:8000/
helloA.py
import sys
from django.conf import settings
settings.configure(
DEBUG=True,
SECRET_KEY='thisisthesecretkey',
ROOT_URLCONF=__name__,
MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
),
)
from django.conf.urls import url
from django.http import HttpResponse
def index(request):
return HttpResponse('Hello World')
urlpatterns = (
url(r'^$', index),
)
if __name__ == "__main__":
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
(稍后补充)