I can't find this in the docs. When I run python manage.py collecstatic --no-input
does it mean it will answer "yes" to any prompt that would pop up in the process? The same for python manage.py migrate --no-input
.
Django manage.py --no-input . Yes or no?
Asked Answered
For collectstatic:
message.append(
'Are you sure you want to do this?\n\n'
"Type 'yes' to continue, or 'no' to cancel: "
)
if self.interactive and input(''.join(message)) != 'yes':
raise CommandError("Collecting static files cancelled.")
So for collect static, if you set --no-input
it will set interactive
to False
and, as you can see above, will answer yes
to the question for you.
For migrate it is much trickier because of django signaling. The migrate
management itself does not ask any questions, but other installed apps may hook into the pre_migrate_signal
or post_migrate_signal
and handle interactivity in their own way. The most common one I know of is contenttypes
For contenttypes
, --no-input
answers "no" as in "No, please don't delete any stale contenttypes":
if interactive:
content_type_display = '\n'.join(
' %s | %s' % (ct.app_label, ct.model)
for ct in to_remove
)
ok_to_delete = input("""The following content types are stale and need to be deleted:
%s
Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.
Type 'yes' to continue, or 'no' to cancel: """ % content_type_display)
else:
ok_to_delete = False
© 2022 - 2024 — McMap. All rights reserved.
yes
, but I've noticed before bugs with it failing to remove stale content types. code.djangoproject.com/ticket/25036 – Enthuse