Create a django project through pycharm

1. Install django

Install the Django package directly using pip: Django2.2.7、django-extensions2.2.5、django-log-request-id1.4.0 、 django-redis4.10.0。

2. Use pycharm to create a django project:

The steps to create django are as follows:
Insert picture description here
the project after creation is as follows:
Insert picture description here
each app serves as a basic functional module, if there is a new functional module, you can add a new app, which is conducive to better management of the code, which is added The method of the new app is as follows, refer to Django in creating an app : the
Insert picture description here
Insert picture description here
Insert picture description here
functions and points of attention of some files under the project:

  • manage.py: A practical command line tool that allows you to interact with the Django project in various ways. Under normal circumstances, this file should not be edited.
  • init .py: An empty file, telling Python that the directory is a Python package.
  • settings.py: Project settings/configuration. A lot of content will be added later according to the project.
  • wsgi.py: The entry to the web server compatible with the WSGI protocol, which is needed during deployment, and generally does not need to be modified.
  • pemplates: This folder is used to put html files, front-end pages, if you don't have one, you can create one yourself.
  • models: Operate the database and define the table structure
  • view: write the main logic

3. The relationship between project and app:

The app is an integral part of the django project. An app represents a module in the project, and all URL requests are handled by the app. For example, Douban has many modules such as books, movies, music, and the same city. From the perspective of django, the modules of books and movies are apps. Books and movies together form the Douban project. Therefore, there must be a concept here. The Django project is composed of many apps. One app can be used in other projects, and Django can also have different apps.

Guess you like

Origin blog.csdn.net/yangdashi888/article/details/114371613