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.
tentest/doc/DjangoBlog/djangoblog/apps.py

29 lines
1.4 KiB

This file contains ambiguous Unicode characters!

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.

#wr 从Django的apps模块导入AppConfig类该类是所有应用配置的基类
from django.apps import AppConfig
class DjangoblogAppConfig(AppConfig):
"""
wr 自定义应用配置类,用于配置'djangoblog'应用的行为
继承自Django的AppConfig可自定义应用初始化、信号注册、插件加载等逻辑
"""
#wr 指定模型默认的自增字段类型Django 3.2+新增配置)
#wr BigAutoField是大整数类型的自增字段可支持更大范围的ID值避免整数溢出
default_auto_field = 'django.db.models.BigAutoField'
#wr 应用的名称必须与应用的目录名一致Django通过此名称识别应用
name = 'djangoblog'
def ready(self):
"""
wr 应用就绪时执行的方法Django加载完应用后自动调用
通常用于执行初始化操作,如注册信号、加载插件、启动定时任务等
"""
#wr 调用父类的ready方法确保基类的初始化逻辑正常执行
super().ready()
#wr 导入并加载插件(应用就绪后加载插件,确保插件依赖的资源已初始化)
#wr 从当前应用的plugin_manage.loader模块导入load_plugins函数
from .plugin_manage.loader import load_plugins
#wr 执行插件加载函数,完成插件的注册和初始化
load_plugins()