Pycharmcreate the specified version of Django


Recently, I was studying the enterprise level development practice of Django by the 5fire. When I want to create Django project with pycharm, I can’t import the correct environment in pycharm after creating virtual environment with virtualenv. Django is not importable in this environment. After a long time of research, the method of pycharms to create the specified version of Django is recorded as follows.

My environment: 1. Pycharm2018.3.5 64 bit professional 2. Python 3.6.8 3. System: win7

Target version: Django 1.11.20

Formal start of steps:

1. First create a pure Python project

Project name MySite

Select new envelope using. In this way, a new, independent and isolated project environment can be built to avoid great confusion in Python environment management.

There are many options:

I chose virtualenv, but pipenv was not used. CONDA’s package is comprehensive. However, anaconda3 in my win10 often cannot be opened, which seriously affects the development experience and consumes system resources.

The location of this new environment is under MySites project. Please note that you may use the environment name of other projects. It is suggested to modify it. Click the folder like button on the right, and a window on the right will pop up, which can be modified

Enter project name

Create another MySite? Env directory under MySite as the virtual environment directory

It will be like this after modification

Base interpreter refers to the original location of the python you use, that is, the location of your native Python interpreter. Pycharm will copy this interpreter in the virtual environment created by the project, without affecting the native Python interpreter.

Click Create

2. You will be asked if the folder is not empty. Do you want to create it in an empty folder

You will be asked whether to open in the current window or in a new window. Select one.

3. Click the file option on the left, and then click setting

4. Click Project: MySite (MySite is the name of the project you created), and then click project interpreter

You can see that the project is very clean. Click the plus sign on the right to download the required Django version

Enter Django in the upper left corner, search, check specify version in the lower right corner, select the specific version you need in the drop-down box on the right, and then click Install Package in the lower left corner

After the installation is successful, the

5. The directory structure at this time is as follows

Click the terminal in the lower left corner. The name of the virtual environment is displayed on the left. Enter Django admin startproject MySite on the command line to create a Django project named MySite

After execution, you will find that the directory structure has changed

6. Click Add configuration on the right, and then click the plus sign in the upper left corner of the pop-up window

Select Django server

Select fix in the lower right corner

Select enable Django support and click the folder button on the right of Django project root to select MySite in the next level,

At this point, will be found automatically

Click the folder button on the right of setting, and select under MySite

Click OK

Change name to MySite

7. The upper right corner will display as follows. Click the green triangle to run

Appear below

Click the blue link, and it is recommended to use Chrome browser (QQ browser sometimes can’t be opened)

The following figure shows that Django runs successfully

Start programming happily!!!

The above is the whole content of this article. I hope it will help you in your study, and I hope you can support developepaer more.