Build Python-django Environment under Mac

Source: Internet
Author: User

    1. Install Python.
    2. Select the Python version. If there is a python2.* version on the machine, enter Python in the command line to enter the python2.* environment. If there is a python3.* version on the machine, enter Python3 in the command line to enter the python3.* environment.
    3. In pycharm, switch python version,files-> Default setting->project interpreter and select the Python version to run.
    4. Switch python version-from the Web, this machine does not switch so. The installation is complete, but you will see that the Python version is still available on your Mac with the Python 2.7 version. So how to change to the latest version: Check the current python command location: Whereis python, mine is/usr/bin/python, back up the current Python:mv/usr/bin/python/usr/bin/python_ Default_backup (may require sudo for administrator rights), this version is not executed by default when Python is executed, looking for the installation location of the newly installed version of Python, by default in/usr/local/bin/ The new version is usually the same as the previous version of the Python location. You can check the Ls-al <python command location to see the soft connection pointing to location > to determine. Set the new version to the default version under/usr/bin/to set a new version of soft connect ln-s/usr/local/bin/python3.4/usr/bin/python.
    5. Install Django, I am installed under the official website of the installation package.
    6. View the Django version and execute the following command sequentially
python>>> Import Django>>> Print (Django.get_version ())-The python2 above is used.
  1. Create a Django project, according to the official documentation, by executing the django-admin startproject < website name, and this completes the project creation. Note that in some previous versions, the project was created using django-admin.py in Python. The premise is to switch to the /usr/bin directory first, then run django-admin or django-admin.py, you can use django-admin Help to view and learn.
  2. Looking at the Django project directory, a directory named after the project name is created in your current directory.
  3. Switch to this directory, LS view directory project, this directory will have the file manage.py.
  4. Run in this directoryPython manage.pyRunserver, start the server, and you'll see,django version 1.11.1, Using Settings ' judypython.settings '
    starting Development Server at Http://127.0.0.1:8000/
    quit the server with Control-c.
    [09/jun/2017 02:47:27] "get/http/1.1" 1716
    not Found:/favicon.ico
    [09/jun/2017 02:47:27] Span style= "FONT-SIZE:14PX; Color: #000000; Line-height:normal; Font-family:menlo ">" Get/favicon.ico http/1.1 "404 1966
  5. Use 127.0.0.1:8000 to see the effect, there will be a message,
    1. It worked!
      Congratulations on your first django-powered page.
      Next, start your first app by running Python manage.py Startapp [App_label].
      You ' re seeing the this message because you has DEBUG = True in your Django settings file and you haven ' t configured any URLs. Get to work!

Build Python-django Environment under Mac

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.