Django installation operation tutorial

1. Environment preparation

Make sure python and pycharm tools are installed

Two, django installation and configuration environment variables

Method 1: Command installation in cmd

pip install -i https://pypi.douban.com/simple django
或 指定相应的django版本:
>pip install -i https://pypi.douban.com/simple django==2.0

This command with a mirror is very fast to install and will not report an error. It will automatically download the latest version of django and be automatically installed in the site-packages folder under Lib under the python installation path. For example: go to cmd and
insert image description here
enter Order:

>python
>>import django

Check whether django is installed successfully. If successful, the following steps to configure environment variables can be skipped directly.

1. Open the bin folder in the django folder:

insert image description here

insert image description here

2. Add the bin directory of django: D:\Program Files\Python36\Lib\site-packages\django\bin to the system environment variable, as shown in the figure below, click Path in the system variable, and select Edit:

insert image description here

insert image description here

3. Select New, paste the bin directory directly, and then click all the way to confirm and exit

Note: In the screenshot below, the two paths in 3 that I framed should also be added to the environment variables. Check if there is any missing
insert image description here

4. After the environment variables are configured, open cmd, check whether django is installed, and enter the following commands respectively:
>python
>>>import django
>>>django.get_version()

The following interface appears, indicating that the installation is successful
insert image description here

Method 2: Install directly using pycharm

insert image description here
insert image description here
insert image description here

insert image description here

3. Create your first Django project

After the django environment is configured, you can go to the command prompt to create the first django application
After using the virtual environment to build the django project, in the pycharm terminal, use the cd command to return to the root directory of pycharmprojects, and use djano-admin to build the django project
insert image description here

Guess you like

Origin blog.csdn.net/weixin_37864926/article/details/127124197