报错:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
方法一:
> pip install MySQL-python
方法一由于网络和编译环境的原因失败率大,最好选用方法二。
方法二:
下载MySQL-python,到sourceforge.net,点击下载
Handlebars provides the power necessary to let you build semantic templates effectively with no frustration.
Handlebars templates look like regular HTML, with embedded handlebars expressions.
A handlebars expression is a {{, some contents, followed by a }}
Handlebars.js大概就是供给js渲染的一种模版吧,他是用{{, }}这样的标记,但是会和Django本来的模版标记冲突。
Stops the template engine from rendering the contents of this block tag.
A common use is to allow a JavaScript template layer that collides with Django’
Git可以将用户名,密码和仓库链接保存在硬盘中,而不用在每次push的时候都输入密码。
保存密码到硬盘一条命令就可以
$ git config credential.helper store
当git push的时候输入一次用户名和密码就会被记录
参考
$ man git | grep -C 5 password
$ man git-credential-store
这样保存的密码是明文的,保存在用户目录~的.git-credentials文件中
$ file ~/.git-credentials
$ cat ~/.git-credentials
引用
EXAMPLES
The point of this helper is to reduce the number of times you must type your username or password. For example:
$ git config credential.helper store $ git push http://example.com/repo.git
settings.py 中设置 LANGUAGE_CODE,以使Django支持需要的语言,如简体中文。
将
LANGUAGE_CODE = 'en-us'
修改为
LANGUAGE_CODE = 'zh-hans'
Django 支持中文,可以体现在后台admin页面被汉化,时间支持中文。例如
{{ pub_date|date:"Y-m-d, l" }}
显示的是例如"2016-05-25, 星期三",而不是"2016-05-25, Wedesday"这样的时间,省去了开发者自己汉化的步骤。
Django1.9以后language code 'zh-cn'就被丢弃了,使用'zh-hans'代替。
The use of the language code 'zh-cn' is deprecated. Please use the 'zh-hans' translation instead.
假设body有命名空间如下
<body xmlns="http://www.w3.org/1999/xhtml">
那么直接用response.xpath取body
response.selector.register_namespace('w', 'http://www.w3.org/1999/xhtml')
body = response.xpath('//w:body').extract()
上面的这个response.selector实际上是scrapy.selector.XmlXPathSelector,等同于
from scrapy.selector import XmlXPathSelector
x = XmlXPathSelector(response)
x.register_namespace('g', 'http://www.w3.org/1999/xhtml')
x.select('//g:body')