3👍
✅
You’re passing a wrong argument to the execute_from_command_line
method. You should do something like below:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "<package>.<subpackage>.settings") #path to the settings py file
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
OR
#!/usr/bin/env python
import os
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "<package>.<subpackage>.settings") #path to the settings py file
from django.core.management import execute_from_command_line
execute_from_command_line() # by default sys.argv argument is taken
Indeed, the argument of execute_from_command_line
is, as its name suggests, a parsed command line where the 1st element is the executable name, and the others are arguments
Source:stackexchange.com