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
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:
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:
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
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
Method 2: Install directly using pycharm
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