django ORM 简单示例简绍

简单 models 操作

1 class Host(models.Model):
2     nid = models.AutoField(primary_key=True)    #Nid为主键
3     hostname = models.CharField(max_length=32,db_index=True)  # db_index=true 表示创建索引
4     ip = models.IPAddressField(db_index=True)
5     port = models.IntegerField()

 

posted @ 2017-02-23 00:20  李瑞鑫  阅读(159)  评论(0编辑  收藏  举报