Python 96th Day---Django (1)

Source: Internet
Author: User

Django Module

One installation:

PIP3 Install Django

Or

python-m pip Install Django

Two Add environment variables

Related commands:

1 # cmd under 2  3 django-admin startproject  name# folder name 45 python manage.py Runserver  127.0.0.1:8000# boot

Django creates the project catalog feature

Name

-name #整个程序进行配置目录

--init

--settings #配置文件

--urls #usr对应关系

--wsgi #WSIG规范 (Uwsgi+nginx)

--manage.py #管理Django程序

Related commands:

Python manage.py makemigrations #操作数据库

Python manage.py Migrate

App Catalog

-migrations Data Manipulation record (modify table structure)

--apps #配置当前的app

--models #创建数据库表结构 (ORM writes a specified class, creates a table from a command)

--tests #单元测试

--views #业务代码

Django Base Usage

A path to the configuration template (the new Django default has it)

--settings #配置文件

' DIRS ': [Os.path.join (Base_dir, ' templates ')],

Two configuration static file paths

Create directory static

Statcfiles_dirs= (

Os.path.join (Base_dir, ' static '

)

Django Template language

  

1 {% for row in user_list%}2      <TR>3            <TD>{{Row.username}}</TD>4             <TD>{{Row.email}}</TD>5              <TD>{{Row.sex}}</TD>6 7     </TR>8{% ENDFOR%}

Django Request Cycle

Python 96th Day---Django (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.