django-extensions
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDjango Extensions
Django Extensions
This project has django-extensions installed. Use these commands to understand and interact with the Django project.
本项目已安装django-extensions。可使用以下命令来了解并与Django项目进行交互。
Introspection
项目内省
Show URL Routes
查看URL路由
bash
python manage.py show_urlsbash
python manage.py show_urlsList Model Information
列出模型信息
bash
undefinedbash
undefinedAll models
所有模型
python manage.py list_model_info
python manage.py list_model_info
Specific model with signatures and field classes
带签名和字段类的指定模型
python manage.py list_model_info --model <app.Model> --signature --field-class
python manage.py list_model_info --model <app.Model> --signature --field-class
All methods including private
包含私有方法在内的所有方法
python manage.py list_model_info --model <app.Model> --all-methods --signature
undefinedpython manage.py list_model_info --model <app.Model> --all-methods --signature
undefinedPrint Settings
打印配置信息
bash
undefinedbash
undefinedAll settings
所有配置
python manage.py print_settings --format=pprint
python manage.py print_settings --format=pprint
Wildcards supported
支持通配符
python manage.py print_settings AUTH*
python manage.py print_settings DATABASE*
python manage.py print_settings *_DIRS
undefinedpython manage.py print_settings AUTH*
python manage.py print_settings DATABASE*
python manage.py print_settings *_DIRS
undefinedShow Permissions
查看权限
bash
python manage.py show_permissions
python manage.py show_permissions <app_label>bash
python manage.py show_permissions
python manage.py show_permissions <app_label>Show Template Tags
查看模板标签
bash
python manage.py show_template_tagsbash
python manage.py show_template_tagsDevelopment
开发调试
Enhanced Shell (shell_plus)
增强版Shell(shell_plus)
bash
python manage.py shell_plus
python manage.py shell_plus --print-sqlAuto-imports all models. Use to skip apps.
--dont-load app1bash
python manage.py shell_plus
python manage.py shell_plus --print-sql自动导入所有模型。可使用参数跳过指定应用。
--dont-load app1Enhanced Dev Server (runserver_plus)
增强版开发服务器(runserver_plus)
bash
python manage.py runserver_plus
python manage.py runserver_plus --print-sqlIncludes Werkzeug debugger for interactive debugging.
bash
python manage.py runserver_plus
python manage.py runserver_plus --print-sql集成Werkzeug调试器,支持交互式调试。
Database
数据库操作
SQL Diff (Compare Models to Schema)
SQL差异对比(模型与架构对比)
bash
python manage.py sqldiff -a # SQL differences
python manage.py sqldiff -a -t # Text differences (readable)bash
python manage.py sqldiff -a # SQL语句差异
python manage.py sqldiff -a -t # 可读文本格式差异Script Execution
脚本执行
Run Scripts with Django Context
在Django上下文环境中运行脚本
bash
python manage.py runscript <script_name>
python manage.py runscript <script_name> --script-args arg1 arg2
python manage.py runscript <script_name> --tracebackScripts in directory must define a function.
scripts/run()bash
python manage.py runscript <script_name>
python manage.py runscript <script_name> --script-args arg1 arg2
python manage.py runscript <script_name> --tracebackscripts/run()Profiling
性能分析
Profile Server Requests
分析服务器请求性能
bash
python manage.py runprofileserver --prof-path=/tmp/profiles
python manage.py runprofileserver --use-cprofile --prof-path=/tmp/profiles
python manage.py runprofileserver --kcachegrind --prof-path=/tmp/profilesbash
python manage.py runprofileserver --prof-path=/tmp/profiles
python manage.py runprofileserver --use-cprofile --prof-path=/tmp/profiles
python manage.py runprofileserver --kcachegrind --prof-path=/tmp/profilesNotes
注意事项
- Model notation: (e.g.,
app.ModelName,core.EmailAccount)metabox.Thread - Settings wildcards: ,
AUTH*,*_DIRSDATABASE* - Commands run from project root
- 模型表示方式:(例如:
app.ModelName,core.EmailAccount)metabox.Thread - 配置通配符:,
AUTH*,*_DIRSDATABASE* - 所有命令需在项目根目录下执行