How to start and run Django project in pycharm. The Django project is not recognized in pycharm. Manually add startup items.

Preface

When working on a practical training project with a group, I found that many friends did not know how to start the Django project. Here is a way to add a project startup.

Solution

Note that if you switch to Chinese, you can find the one with the same meaning, or you can simply locate it based on the relative position.

1. Find the run box in the upper right corner of the Django interface, click on the file to expand it (the downward-facing triangle), and then click on Edit Configurations... as shown in the picture.

2. Click the plus sign + in the upper left corner of the pop-up interface

 

3. Find the options for Python

 

4. After selecting Python, in your new Python run settings, find the Script path location as shown in the picture, and select the manage.py file in your Django project

 

5. Then write runserver in the Parameters column below

 

6. After the setting is completed, click OK in the lower right corner

  

7. Then click the green right triangle in the box to run the Django project.

 principle

In fact, it is equivalent to typing in the command box

python manage.py runserver

If you don’t believe it, you can enter this line of code in the Terminal below to see if the running effect is the same.

 

Notice! When you are in the terminal (that is, Terminal), make sure that the folder you select contains manage.py, not the upper or lower level!

 expand

There are many other operations in the terminal, including creating apps.

python manage.py createapp app名字

 There are also key commands such as database migration, etc.

python manage.py makemigrations
python manage.py migrate

If you are only responsible for other modules besides the front-end in group cooperation, and you only need to run the project to see the execution effect, this article will certainly be enough.

But if you want to have a good understanding of the Django framework, then this article is certainly not enough to show how it operates. I suggest staying honest and finding a course online. As long as you watch 2 to 3 hours of video and almost the same amount of practice time typing the code yourself, you will have a deeper understanding of Django, and it will not be difficult to write a simple Django project.

Guess you like

Origin blog.csdn.net/m0_46948660/article/details/127050778