创建django项目(Create Django project)

1、创建Django项目命令:django-admin startproject 项目名注意:创建应用必须先进入虚拟环境。项目目录如下:__init__.py: 说明test1是一个python包。settings.py: 项目的配置文件。urls.py: 进行url路由的配置。wsgi.py: web服务器和Django交互的入口。manage.py: 项目的管理文件。2、创建Django应用一个项目由很多个应用组成的,每一个应用完成一个功能模块。创建应用的命令如下:python manage.py startapp 应用名注意:创建应用时需要先进入项目目录。应用目录如下:__init__.py: 说明目录是一个Python模块。models.py: 写和数据库项目的内容, 设计模型类。views.py: ,接收请求,进行处理,与M和T进行交互,返回应答。定义处理函数,视图函数。tests.py: 写测试代码的文件。admin.py: 网站后台管理相关的文件。3、 应用注册建立应用和项目之间的联系,需要对应用进行注册。修改settings.py中的INSTALLED_APPS配置项。4、 启动项目运行web服务器(开发)命令:python manage.py runserver

————————

1. Create Django project < strong > command: Django admin startproject project project name < / strong > note: to create an application, you must first enter the virtual environment. The project directory is as follows:__ init__. Py: test1 is a python package. settings. Py: configuration file for the project. urls. Py: configure URL routing. wsgi. Py: the portal for the interaction between the web server and Django. manage. Py: management file of the project. 2. Create a Django application project, which is composed of many applications, and each application completes a functional module. The commands for creating applications are as follows: < strong > Python manage Py startapp application name < / strong > note: when creating an application, you need to enter the project directory first. The application directory is as follows:__ init__. Py: description directory is a python module. models. Py: write and database project content, design model classes. views. Py:, receive the request, process it, interact with m and T, and return the response. Define processing functions and view functions. tests. Py: a file for writing test code. admin. Py: files related to website background management. 3. Application registration establishes the relationship between the application and the project, and the application needs to be registered. Modify settings Installed in PY_ Apps configuration item. 4. Start the project < strong > run the web server (Development) command: Python manage py runserver