我的模型包含所有资产(打印机,计算机,扫描仪,照片复印机......),我将其保存在一个表格中,如下所示:
class Assets(models.Model):
Tag = models.CharField (max_length = 20, unique=True)
SN = models.CharField (max_length = 20, unique=True)
IP = models.IPAddressField (null=True, blank=True)
MacAddress = models.CharField (max_length = 25, null=True, blank=True)
AssetsType = (
('Printer','Printer'),
('Monitor','Monitor'),
('Scanner','Scanner'),
('Personal Computer','PC'),
('Laptop','Laptop'),
('IPAD', 'IPad'),
('IMAC', 'IMac'),
('PhotoCopier','PhotoCopier'),
)
Type = models.CharField (max_length = 25 , choices= AssetsType)
employee = models.ForeignKey (Employee, null=True, blank=True)
building = models.ForeignKey (Location, to_field ='Building', related_name = 'Buliding_Name')
问题是,如果用户选择打印机,我想询问哪种类型的打印机,而对于扫描仪,我想问一下所用扫描仪的类型?
我希望只有当用户选择打印机或扫描仪时,才会显示扫描仪或打印机的类型字段?