Django manage.py --no-input. Yes or no?

I can not find this in the docs. When I run python manage.py collecstatic --no-input , does that mean that it will answer yes to any prompt that appears in the process? Same thing for python manage.py migrate --no-input .

+6
source share
1 answer

You can always just check the django source code. This, you know, is open source.

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, to collect static, if you set --no-input , it will set interactive to False , and as you can see above, answer yes to the question.

For migration, this is much more complicated due to django signaling. The migrate control itself does not ask any questions, but other installed applications can connect to pre_migrate_signal or post_migrate_signal and handle interactivity in their own way. The most common I know that contenttypes

For contenttypes , interactive means No.

  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 
+10
source

Source: https://habr.com/ru/post/1014567/


All Articles