Search code examples
pythondjangoconsole

In Django, what is the difference between running "python manage.py shell" or just "python"?


In the context of Django, both python manage.py shell and python can start a Python interpreter. What is the difference between these commands?


Solution

  • Directly typing python, just starts the interpreter.

    Using manage.py within a django project sets the environment so that you can interact with your project objects in the shell. As noted here:

    We’re using this instead of simply typing “python”, because manage.py sets the DJANGO_SETTINGS_MODULE environment variable, which gives Django the Python import path to your mysite/settings.py file.