在model中定义一个设备分组:
class DeviceGroup(CoreModel):
name = models.CharField(blank=False, null=False, max_length=64, help_text='名称')
dept = models.ForeignKey(Dept, blank=True, null=True, on_delete=models.CASCADE, help_text='部门')
parent = models.ForeignKey('self', null=True, blank=True, related_name='children', verbose_name='上级分组',
on_delete=models.SET_NULL)
is_root = models.BooleanField(default=False, help_text='是否根目录')
index = models.IntegerField(default=0, help_text='排序索引')
function_field = models.JSONField(blank=True, null=True, help_text='默认代码')
function_text = models.TextField(blank=True, null=True, help_text='默认代码文本')
is_show = models.BooleanField(default=True, help_text='是否显示')