def inner_run(self, *args, **options):
[ Earlier irrelevant code omitted ...]
self.stdout.write("Performing system checks...\n\n")
self.check(display_num_errors=True)
# Need to check migrations here, so can't use the
# requires_migrations_check attribute.
self.check_migrations()
[ ... more code ...]
字符串
解决方案
你可以做的是派生你自己的run命令,它接受runserver命令,但覆盖执行检查的方法:
from django.core.management.commands.runserver import Command as RunServer
class Command(RunServer):
def check(self, *args, **kwargs):
self.stdout.write(self.style.WARNING("SKIPPING SYSTEM CHECKS!\n"))
def check_migrations(self, *args, **kwargs):
self.stdout.write(self.style.WARNING("SKIPPING MIGRATION CHECKS!\n"))
Performing system checks...
SKIPPING SYSTEM CHECKS!
SKIPPING MIGRATION CHECKS!
January 18, 2017 - 12:18:06
Django version 1.10.2, using settings 'foo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
def inner_run(self, *args, **options):
[ Earlier irrelevant code omitted ...]
if not options["skip_checks"]:
self.stdout.write("Performing system checks...\n\n")
self.check(display_num_errors=True)
# Need to check migrations here, so can't use the
# requires_migrations_check attribute.
self.check_migrations()
[ ... more code ...]
3条答案
按热度按时间sshcrbum1#
问题
不幸的是,没有命令行参数或设置可以打开以关闭
runserver
中的检查。* 一般情况下 *,有--skip-checks
选项可以关闭系统检查,但它们对runserver
没有用处。如果你阅读
runserver
命令的代码,你会看到它基本上忽略了requires_system_checks
和requires_migration_checks
标志,而是在其inner_run
方法中显式调用self.check()
和self.check_migrations()
,无论如何:字符串
解决方案
你可以做的是派生你自己的
run
命令,它接受runserver
命令,但覆盖执行检查的方法:型
你需要把它放在
<app>/management/commands/run.py
下,其中<app>
是任何合适的应用程序应该有这个命令。然后你可以用./manage.py run
调用它,你会得到这样的东西:型
rdlzhqv92#
有一件事可能会加快PyCharm的调试器,那就是关闭“Collect run-time types information for code insight”设置:位于File > Settings > Build,Execution,Deployment > Python调试器下。
kpbpu0083#
我没有足够的声誉来评论Louis' answer,但是从django 4.0开始,
runserver
命令不再显式调用self.check()
。它现在基于--skip-checks
选项有条件地运行。字符串
换句话说,
python manage.py runserver --skip-checks
将跳过系统检查。查看更改日志和代码