Article From:https://www.cnblogs.com/wuheng1991/p/9906584.html

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:
  __init__.py:This is an initialized empty file, and we don’t need to move it.
  settings.py: This is a configuration file with information about language, time zone, app declaration for installation, etc.
  urls.py: 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.
  wsgi.py: This is a WSGI configuration for web applications, and we don’t need to modify it for the time being.
  manage.py: 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 management.py file of the project created above, such as:

Then use manage.py to create an app and enter the following commands:python manage.py 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 management.py, execute:python manage.py runserver 8080, Among them, 8080 is the port.

 

 

Leave a Reply

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