command to start the Python interpreter (the difference between Python manage.py shell and Python)

Source: Internet
Author: User

If you've ever used Python, you must be wondering why we run python manage.py shell instead of python. Both commands start the interaction interpreter, but the manage.py Shell command has an important difference: it tells Django which settings file to use before starting the interpreter. Most subsystems of the Django framework, including the template system, are dependent on the configuration file and will not work if Django does not know which configuration file to use.

If you want to know, here will explain how it works behind you. The Django Search django_settings_module environment variable, which is set in settings.py. For example, suppose MySite is in your Python search path, then django_settings_module should be set to: ' Mysite.settings '.

When you run the command: Python manage.py shell, it will automatically handle the django_settings_module for you. In the current examples, we encourage you to use the "Python manage.py shell" approach, which frees you from the hassle of configuring environment variables that you are unfamiliar with.

As you become more familiar with DJANGO, you may be inclined to discard the "manage.py shell" instead of using the "the", and manually add the django_settings_module in your config file . bash_profile this environment variable.

command to start the Python interpreter (the difference between Python manage.py shell and Python)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.