[django]让 BigIntegerField 字段自增长

默认的 id 字段是 IntegerField 属性,长度是 11。

现在要将它改为 BigIntegerField 属性,因为它的长度是更长。

class Foo(models.Model):
    id = models.BigIntegerField(primary_key=True)
    #...

更改后的数据库字段信息:

mysql> desc foo_bar;
+--------------+------------+------+-----+---------+-------+
| Field        | Type       | Null | Key | Default | Extra |
+--------------+------------+------+-----+---------+-------+
| id           | bigint(20) | NO   | PRI | NULL    |       |

问题出来了,更改后的 id 没有自增长的功能。

解决办法就是自定义一个字段属性:

代码结构:

foo   # app
|-fields.py
|-models.py

代码:

# fields ...
more ...

[javascript]列出对象所有属性

当我们想知道某个对象拥有哪些的属性时,可以用下面的方法(现代浏览器):

var properties = Object.keys(obj);

这个方法对于我们使用第三方 javascript 插件,而该插件的文档不是很详细时有很大的帮助

trackFormatter: function(obj){
  console.debug('properties:');
  console.debug(Object.keys(obj));
}

console debug object properties image

参考

more ...

[linux]screen 常用命令

通过 screen 命令可以让终端命令在我们断开远程服务器后依旧运行而不会中断。

安装 screen 命令

redhat/centos:

yum install screen

ubuntu:

sudo apt-get install screen

常用的 screen 命令

新建一个名为 django 的 screen shell:

screen -S django

新建一个名为 django 的后台 screen shell:

screen -dS django

查看所有的 screen shell:

$ screen -ls
There are screens on:
    1429.django (Detached)
    23264.abc   (Detached ...
more ...