Python Development Learning-DAY15 (front-end part knowledge, web framework, Django Creation project)

Source: Internet
Author: User
Tags sessions install django jquery library pip install django

S12-20160430-day15

Pytho Automation Development day15date:2016.04.30
    @南非波波

Course Outline:

Http://www.cnblogs.com/wupeiqi/articles/4491246.html http://www.cnblogs.com/wupeiqi/articles/4508271.html

First, the front-end design

1. Implement Picture Carousel

js:    http://bxslider.com/引入    <!-- jQuery library (served from Google) -->    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>    <!-- bxSlider Javascript file -->    <script src="/js/jquery.bxslider.min.js"></script>    <!-- bxSlider CSS file -->    <link href="/lib/jquery.bxslider.css" rel="stylesheet" />加载图片:    <ul class="bxslider">      <li></li>      <li></li>      <li></li>      <li></li>    </ul>调用:     $(document).ready(function(){      $(‘.bxslider‘).bxSlider();    });

2. Icon Resources

Font Awesome    http://fontawesome.io/    a、图片,自己找图片,挖洞    b、现成的图标        css        使用样式        --以前版本            css            图片库            使用样式        -- 现在            css            字体文件            使用样式    c、css        字体文件        样式    =====》 大图片

3. Pseudo-Class

<!DOCTYPE html>
Second, the web framework

1.python Web Framework Classification

#!/usr/bin/env python#coding:utf-8import socketdef handle_request(client):    buf = client.recv(1024)    client.send("HTTP/1.1 200 OK\r\n\r\n")    client.send("Hello, Seven")def main():    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)    sock.bind((‘localhost‘,8000))    sock.listen(5)    while True:        connection, address = sock.accept()        handle_request(connection)        connection.close()if __name__ == ‘__main__‘:    main()

2.MVC Web Framework

MVC:Models  Views Controllers        数据库操作 模板  处理请求的函数代码块的归类结构MTV:Models Templates Views    数据库操作 模板  处理请求的函数

3.Django Foundation

Django框架属于MTV框架。程序需要的操作的:    1.models    2.Templates    3.Views    4.urls
Third, Django

1. Installation

pip install django 1.9.5

2. Create a Django program framework

使用命令创建    django-admin startproject demo 创建projects    cd demo    python manage.py startapp app0 创建应用使用pycharm进行创建项目和应用

3. Execution procedures

进入项目, python manage.py runserver 127.0.0.1:8000

4. Create a data table

python manage.py makemigrations #生成配置文件python manage.py migrate       #根据配置文件创建数据库相关 表

5.django Default Background Management

创建超级用户名 python manage.py createsuperuser

6. Routing system

静态路由动态路由    安照顺序,第n个匹配的数据交给函数的第n个参数,严格按照顺序        url(r‘^page/(\d+)/(\d+)‘,views.page)    模板的方法,将匹配的参数,传给指定的形式参数        url(r‘^page/(?P<n1>\d+)/(?P<n2>\d+)‘,views.page)二级路由    app01        urls.py    project name         URL:app01 ->include("app01.urls")

7. Basic Database Operations

ORM Framework Code first writes its own class--database table DB first writes its own command operations database--Update classes use classes for data manipulation to create classes from django.db Import Models class UserInfo (models. Model): Username = models. Charfield (max_length=32) password = models. Charfield (max_length=32) Age = models.             Integerfield () configuration setting Installed_apps = [' django.contrib.admin ', ' Django.contrib.auth ',            ' Django.contrib.contenttypes ', ' django.contrib.sessions ', ' django.contrib.messages ',    ' Django.contrib.staticfiles ', ' app01 ',] use the command to create a table based on the class Python manage.py makemigrations #生成配置文件     Python manage.py migrate #根据配置文件创建数据库相关 table default table name: Appname_classnamed.    Views in the import Modelse. Post submission data settings: middleware_classes = [' Django.middleware.security.SecurityMiddlewa Re ', ' django.contrib.sessions.middleware.SessionMiddleware ', ' Django.middleware.common.Commo NmiddlEware ', # ' Django.middleware.csrf.CsrfViewMiddleware ', ' Django.contrib.auth.middleware.Authen Ticationmiddleware ', ' django.contrib.auth.middleware.SessionAuthenticationMiddleware ', ' Djan Go.contrib.messages.middleware.MessageMiddleware ', ' Django.middleware.clickjacking.XFrameOptionsMiddleware ' ,            ]

Python Development Learning-DAY15 (front-end part knowledge, web framework, Django Creation project)

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.