標籤:any lap pen pre choice accept max open img
1、建立項目
2、建立models
from django.db import models# Create your models here.# 主機表class Host(models.Model): # 主機名稱 hostname = models.CharField(max_length=128,unique=True) # 主機key key = models.TextField() # 主機狀態 # 等待同意 status_choices = ((0,‘Waiting Approval‘), # 已同意 (1,‘Accepted‘), # 已拒絕 (2,‘Rejected‘)) # 主機系統類別型 os_type_choices =( (‘redhat‘,‘Redhat\CentOS‘), (‘ubuntu‘,‘Ubuntu‘), (‘suse‘,‘Suse‘), (‘windows‘,‘Windows‘), ) os_type = models.CharField(choices=os_type_choices,max_length=64,default=‘redhat‘) status = models.SmallIntegerField(choices=status_choices,default=0) def __str__(self): return self.hostname# 主機群組class HostGroup(models.Model): # 組名 name = models.CharField(max_length=64,unique=True) # 屬於該組的主機 hosts = models.ManyToManyField(Host,blank=True) def __str__(self): return self.name
models
3、初始化資料庫
Python自動化開發(一)【未完待續】