【发布时间】:2018-04-05 02:41:20
【问题描述】:
我正在尝试在 django 中编写管理命令。根据documentation 默认设置为False。我会假设默认值是正在传递的参数的默认值。 Make django custom management command argument "Not Required"
声明deafult=False有什么好处
class Command(BaseCommand):
help = "helps in doing stuff"
def add_arguments(self, parser):
parser.add_argument(
'name', type=str, default=False,
help="The name of the folder to be created")
def handle(self, *args, **options):
pass
【问题讨论】:
-
“根据文档默认设置为 false”是什么意思?您可以将默认设置为任何您想要的。
标签: python django django-management-command