0

I have following code in manage.py file inside django project:

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
    from django.core.management import execute_from_command_line

    print 'command for running'

    execute_from_command_line(sys.argv)

I'm getting this output:

$ python manage.py runserver
command for running
command for running
Performing system checks...
...

Why command for running is printed twice?

Roman
  • 922
  • 1
  • 8
  • 12
  • 1
    print out sys.argv[0] after your print 'command for running' line - it should be the name of the script.. your call to execute_from_command_line is probably recalling the same script – Alan Kavanagh Jul 16 '16 at 19:48
  • I see. But could not understand why it's needed recalling execute_from_command_line. – Roman Jul 16 '16 at 20:23
  • 1
    Duplicate of [Why is run called twice in the Django dev server?](http://stackoverflow.com/questions/28489863/why-is-run-called-twice-in-the-django-dev-server) and [Why does Popen run twice when using it under if \_\_name\_\_ == "\_\_main\_\_"](http://stackoverflow.com/questions/22324052/why-does-popen-run-twice-when-using-it-under-if-name-main). – solarissmoke Jul 17 '16 at 03:42

0 Answers0