Article From:

1.Install Django

Whether Python 2.x or Python 3.x, you can use pip to install Django. Use the following commands in the console:pipinstall django

Such as:

2.Check if dgango is installed successfully

After successful installation, import Django in IPython or Pycharm’s Python console console and view version information using the following commands:

  a. import django

  b. django.VERSION

Such as:


3. Create a Django program

Command: django-admin start project MySite

Such as:

Here is a brief explanation of these documents: is an initialized empty file, and we don’t need to move it. This is a configuration file with information about language, time zone, app declaration for installation, etc. This file specifies the mapping of views, etc. to be invoked when accessing a page to ensure that you can correctly locate the functions you want to achieve when accessing. This is a WSGI configuration for web applications, and we don’t need to modify it for the time being. It can be understood that he is the control center of Django application, and many commands need to be mobilized.

4. Create an app

Later, when we add a web application, we need to create an app in this way. The specific operation is as follows:
In the Terminal console of CMD or Pycharm, CD enters the path of the file of the project created above, such as:

Then use to create an app and enter the following commands:python startapp blog

5. Startup service

After all the above files are configured correctly, the service can be started. In the CMD or Terminal console, under the path from CD to, execute:python runserver 8080, Among them, 8080 is the port.



Leave a Reply

Your email address will not be published. Required fields are marked *