29. Getting Started with Django, the Web Framework of Python

1. Getting started with Django

  1. Django installation . The installation of django is the same as installing other modules. We find the script directory of the python installation directory, and then execute the command: pip3 install Django. After the installation is complete, you will see the following django-related files in the script directory

After executing this command, add the script directory to the system's environment variables. At this time, we can use Django's commands to execute in any directory of the system. Let's create a new django project.

After the creation is successful, let's first understand the directory structure of the django project.

  Now let's start the project and use the command python manage.py runserver 127.0.0.1:8001 . It should be noted here that python needs to configure environment variables. At the same time, we need to enter the root directory of our project to execute. The following means that the startup is successful. At this time, we can access us by visiting http://127.0.0.1:8001/ 's website,

  It is much simpler to install django in pycharm, and it can be solved in 4 steps by looking at the picture.

  OK, after installation, we use pycharm to create a django project.

After the creation is complete, we see that the directory structure of the project is:

It is exactly the same as what we created on the command line, but there is an additional templates directory. This is created by pycharm for us. Forget it first, then we configure the startup information, and click the startup button of pycharm to complete the startup of the website.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326031848&siteId=291194637