SoFunction
Updated on 2024-11-07

Django project creation and management implementation process details

1. Theme

This part of the tutorial focuses on how to create, manage, and run a Django project through Pycharm. For knowledge about Django modules you can refer to the Python community.

2. Preparing the environment

Django version 2.0 or higher Pycharm version 2017 Python 3.6 interpreter

3. Create a new project

Virtually all projects can be created by clicking on theWelcome screeninterface to the Create New Project button.

If you already have a project open, you can create a new one via the menu bar File → New Project... to create a new project. Next, create a new project in theCreate New Project dialogIn the dialog box, enter the name of the project, the selection type, and the version of the interpreter used.

Click OK and the personalization of the project is complete.

This means that the corresponding directory has been created and an .idea directory has been pre-defined to hold configuration informationproject settings

For an empty projectempty projectThe creation of the program is now complete. Next you can start writing the program. However, for some of the supported third-party frameworks, there is still some work to be done. Depending on the type of project selected, Pycharm will prompt us for some additional framework settings.

In this example, let's create develop a Django application.

Standalone OK, setup complete.

4. Project directory structure

As mentioned above, the root directory structure of the project has already been created and contains mainly the basic framework configuration files and directories, and will operate similarly when you create other types of projects, such as t Pyramid, or Google App Engine.

Next we examine how to display the project structure in the Project window.

5, Project window in the directory structure

6. Project files under Project

If you want to see all directory files, just select the project file mode

7. So what is the role of all the files in the project?

As shown:

It's worth mentioning that you can create a lot of Django applications and add them to the current project by running the file's startapp task (Tools→Run task) command on the main menu.

8, load django service

9. Generate database files

Execute the following command after you have changed the content of the

python makemigrations

It's equivalent to creating a migrations directory under the app and recording all the changes you've made to, say, 0001_initial.py, but the changes haven't been applied to the database files yet.

migrate

10. Add the database window

Add path: view > tool windows > Database

11, visit django page

Open a browser to visit 127.0.0.1:8000 interface, you can appear django home page

This is the whole content of this article.