You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# 赵瑞萍: 评论模型修改迁移模块, 用于调整Comment模型中is_enable字段的默认属性
# 该模块通过Django迁移系统更新评论表结构, 将评论默认显示状态从"显示"改为"隐藏"
# 生成于Django 4.1.7版本,专注于单字段属性的变更操作
# 赵瑞萍: 导入Django数据库迁移核心模块
from django . db import migrations , models # 提供迁移操作类和模型字段类型
class Migration ( migrations . Migration ) :
"""
赵瑞萍:迁移类,封装评论模型字段的修改逻辑
负责将Comment模型的is_enable字段默认值从True改为False, 实现评论默认不显示的功能
"""
# 赵瑞萍:迁移依赖配置,确保执行顺序正确
dependencies = [
( ' comments ' , ' 0001_initial ' ) , # 依赖comments应用的初始迁移, 确保Comment表已存在
]
# 赵瑞萍: 数据库操作列表, 此处为修改is_enable字段属性的核心操作
operations = [
# 赵瑞萍: 修改Comment模型的is_enable字段配置
migrations . AlterField (
model_name = ' comment ' , # 目标模型: comments应用的Comment模型
name = ' is_enable ' , # 目标字段: 控制评论显示状态的is_enable字段
# 赵瑞萍:修改后的字段定义,仅变更默认值
field = models . BooleanField (
default = False , # 关键变更: 默认值从True改为False, 新评论默认不显示
verbose_name = ' 是否显示 ' # 保持后台显示名称不变
) ,
) ,
]