|
@@ -8,14 +8,16 @@ class SchoolDept(MPTTModel):
|
|
|
name = models.CharField(max_length=20)
|
|
|
# 备注字段
|
|
|
remark = models.TextField(null=True)
|
|
|
+ # 父节点
|
|
|
+ parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children_p')
|
|
|
# 创建时间,只有在创建的时候会自动填充当前时间
|
|
|
create_at = models.DateField(auto_now_add=True, verbose_name='创建人')
|
|
|
# 创建人,外键类型
|
|
|
- create_by = models.ForeignKey("self", blank=True, null=True, related_name="children", on_delete=models.CASCADE)
|
|
|
+ create_by = models.ForeignKey("self", blank=True, null=True, related_name="children_c", on_delete=models.CASCADE)
|
|
|
# 更新时间
|
|
|
update_at = models.DateField(auto_now=True, null=True, verbose_name='最后修改时间')
|
|
|
# 更新人,外键类型
|
|
|
- update_by = models.ForeignKey("self", blank=True, null=True, on_delete=models.CASCADE, verbose_name='最后修改人')
|
|
|
+ update_by = models.ForeignKey("self", blank=True, null=True, on_delete=models.CASCADE, verbose_name='最后修改人',related_name='children_u')
|
|
|
|
|
|
class Meta:
|
|
|
db_table = 'school_dept_tree'
|