1.Django template模板语言 |safe无作用 ?
原因:传入的字符串,必须要按照html标签的正规格式,不能有空格,否则按字符串处理。
后台将字符串如上处理,前端不在需要 |safe
---------------------------------------------------------------------------------------------------------------------------
.CSS
.w_logo{
width: 220px;
height: 55px;
background-image: url(../img/logoo.png);/* 很神奇,为甚../就能找到img目录呢?在index.html中用../就不行呢*/
background-repeat: no-repeat;
background-position: center;
float: left;
}
---------------------------------------------------------------------------------------------------------------------------
验证码报错:使用ImageFont.truetype时跳出OSError: cannot open resource
font_type="arial.ttf"
!!!所写字体样式必须要在C:\Windows\Fonts目录下存在,然后首字母要小写,卧槽,虐心啊
---------------------------------------------------------------------------------------
create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
如果你想在数据库端手动添加时间数据,那么恭喜你,查询到的结果为None。
解决:时间字段是自动添加的,所以要通过admin或create代码添加一行新数据就可以了
---------------------------------------------------------------------------------------
jquery $().each和$.each()的使用:
原文:http://www.frontopen.com/1394.html
$().each 在dom处理上面用的较多。如果页面有多个input标签类型为checkbox,对于这时用$().each来处理多个checkbook,例如:
$(“input[name=’ch’]”).each(function(i){
if($(this).attr(‘checked’)==true)
{
//一些操作代码
}
回调函数是可以传递参数,i就为遍历的索引。
遍历一个数组通常用$.each()来处理 例如:
复制代码
$.each([{name:"limeng",email:"xfjylimeng"},{name:"hehe",email:"xfjylimeng"}],function(i,n)
{
alert("索引:"+i+"对应值为:"+n.name);
});
参数i为遍历索引值,n为当前的遍历对象.
var arr1 = [ "one", "two", "three", "four", "five" ];
$.each(arr1, function(){
alert(this);
});
输出:one two three four five
var arr2 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
$.each(arr2, function(i, item){
alert(item[0]);
});
输出:1 4 7
var obj = { one:1, two:2, three:3, four:4, five:5 };
$.each(obj, function(key, val) {
alert(obj[key]);
});
输出:1 2 3 4 5
-------------------------------------------------------------------------------
这是三个不同类型的数据,例如 2015-11-21 10:51:20:
date是日期,表示的是 2015-11-21;
datetime是日期时间,表示的是 2015-11-21 10:51:20;
time是时间,表示的是 10:51:20。
-------------------------------------------------------------------------------