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.
from django . apps import AppConfig
class DjangoblogAppConfig ( AppConfig ) :
"""
Django 应用配置类,用于定义 ' djangoblog ' 应用的配置信息。
这个类继承自 Django 的 AppConfig, 是应用级别的配置中心,
在 Django 启动时被加载,用于指定应用的行为和初始化逻辑。
"""
# 设置此应用中所有模型默认使用的主键字段类型。
# 使用 BigAutoField 表示默认主键为 64 位整数(支持更大范围的 ID) ,
# 可避免在数据量大时出现整数溢出问题。
default_auto_field = ' django.db.models.BigAutoField '
# 指定该应用的完整 Python 导入路径。
# 必须与应用在项目中的实际路径一致, Django 通过此属性识别应用。
name = ' djangoblog '
def ready ( self ) :
"""
应用准备就绪时调用的方法。
Django 在应用注册系统完全加载后会自动调用此方法,是执行应用级初始化代码的推荐入口点。
常用于:
- 启动后台任务(如 Celery)
- 注册信号处理器( signal handlers)
- 动态加载插件或模块
- 初始化缓存等资源
注意:此方法在整个 Django 启动过程中只会被调用一次。
"""
# 调用父类的 ready() 方法,确保父类的初始化逻辑正常执行
super ( ) . ready ( )
# 导入插件加载函数并执行插件加载
# 通过在 ready() 中调用 load_plugins(),确保插件系统在 Django 完全启动后才被激活
# 这样可以安全地访问 Django 的 ORM 和其他已注册的组件
from . plugin_manage . loader import load_plugins
load_plugins ( )