Skip to content

Latest commit

 

History

History
16 lines (10 loc) · 983 Bytes

笔记.md

File metadata and controls

16 lines (10 loc) · 983 Bytes

https://stackoverflow.com/questions/852414/how-to-dynamically-compose-an-or-query-filter-in-django


Use absolute imports for other Django components and relative imports for local components.


配置文件的最佳实践(TODO)


自定义命令分析

入口是manage.py:django.core.management.execute_from_command_line,然后调用django.core.management.ManagementUtility的execute方法,所以:是ManagementUtility控制命令调用行为,在ManagementUtility类中python manage.py 就已经调用execute方法获取命令传递的settings的值的并通过django.setup()初始化了, 然后再通过self.fetch_command(subcommand).run_from_argv(self.argv)执行子命令, 所以在自定义命令BaseCommand里面更改setting配置的默认值并没有生效.

解决办法: 修改manage.py入口,更改setting路径