随笔分类 -  django

摘要:from functools import wrapsdef wrapper(func): @wraps(func) def inner(request,*args,**kwargs): """ inner的注释: :param request: :param args: :param kwargs 阅读全文
posted @ 2019-12-22 15:46 干it的小张 阅读(205) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-12-22 12:49 干it的小张 阅读(335) 评论(0) 推荐(0)
摘要:import randomfrom PIL import Image, ImageFont, ImageDraw, ImageFilterdef check_code(width=120, height=30, char_length=5, font_file='kumo.ttf', font_si 阅读全文
posted @ 2019-12-22 10:51 干it的小张 阅读(265) 评论(0) 推荐(0)
摘要:from PIL import Image,ImageDraw#生成图片:img = Image.new("RGB",(1000,1000),(255,255,255))#有了画笔:draw = ImageDraw.Draw(img,"RGB")#添加颜色:# draw.point([100,100 阅读全文
posted @ 2019-12-21 17:59 干it的小张 阅读(447) 评论(0) 推荐(0)
摘要:MVC M: model 模型 与数据库交互 V: view 视图 HTML C:controller 控制器 流程 和 业务逻辑 MTV M:model ORM T:template 模板 HTML V:view 视图 业务逻辑 Django中的视图 FBV def add_publisher(r 阅读全文
posted @ 2019-12-19 19:42 干it的小张 阅读(354) 评论(0) 推荐(0)
摘要:示例: 脚本: from django.db import models# Create your models here.class Publisher(models.Model): name = models.CharField(max_length=32) def __str__(self): 阅读全文
posted @ 2019-12-19 17:07 干it的小张 阅读(319) 评论(0) 推荐(0)
摘要:cookie session cookie的定义: 保存在浏览器上的一组组键值对 (请求头) 为什么要有? http协议是无状态,每次的请求之间是相互独立的,没有办法保存状态。 Django中操作cookie 设置 set-cookie reponse.set_cookie(key,value,ma 阅读全文
posted @ 2019-12-18 18:09 干it的小张 阅读(2003) 评论(0) 推荐(0)
摘要:内容回顾: 多对多 class Pulisher(models.Model): name = models.CharField(max_length=32) ​ class Book(models.Model): name = models.CharField(max_length=32) pub 阅读全文
posted @ 2019-12-17 17:26 干it的小张 阅读(417) 评论(0) 推荐(0)
摘要:Django Django处理一个请求的流程 在浏览器的地址栏中输入地址,回车,发了一个GET请求 wsgi模块接收了请求,将请求的相关信息封装成request对象 根据地址找到对应函数 执行函数获取到返回结果,wsgi模块将结果返回给浏览器 发请求的途径 在浏览器的地址栏中输入地址 get请求 a 阅读全文
posted @ 2019-12-16 21:42 干it的小张 阅读(115) 评论(0) 推荐(0)
摘要:Django 下载安装 命令行 pip install django==1.11.26 -i 源 pycharm 创建项目 命令行 django-admin startproject 项目名 pycharm file ——》 new project ——》 django ——》 输入项目路径 ——》 阅读全文
posted @ 2019-12-13 21:41 干it的小张 阅读(224) 评论(0) 推荐(0)
摘要:URL: from django.conf.urls import urlfrom django.contrib import adminfrom app01 import viewsurlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^p 阅读全文
posted @ 2019-12-13 19:59 干it的小张 阅读(204) 评论(0) 推荐(0)
摘要:django配置orm: django使用mysql数据库: 首先cmd创建库 settings配置mysql数据库: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': "day43", 'HOST': 阅读全文
posted @ 2019-12-12 22:43 干it的小张 阅读(160) 评论(0) 推荐(0)
摘要:from django.shortcuts import render,HttpResponse,redirectimport pymysql# Create your views here.def index(request): print(request.path_info) return Ht 阅读全文
posted @ 2019-12-12 21:41 干it的小张 阅读(449) 评论(0) 推荐(0)
摘要:views: from django.shortcuts import render,HttpResponse,redirect# Create your views here.def index(request): print(request.path_info) return HttpRespo 阅读全文
posted @ 2019-12-12 21:09 干it的小张 阅读(240) 评论(0) 推荐(0)
摘要:https://v3.bootcss.com/getting-started/ 查看网页源代码或检查: Ctrl+C+body: 阅读全文
posted @ 2019-12-12 17:33 干it的小张 阅读(264) 评论(0) 推荐(0)
摘要:urls: """day42 URL ConfigurationThe `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/t 阅读全文
posted @ 2019-12-12 17:16 干it的小张 阅读(606) 评论(0) 推荐(0)
摘要:App 创建一个app : python manage.py startapp app01 admin: from django.contrib import admin# Register your models here. apps: from django.apps import AppCon 阅读全文
posted @ 2019-12-12 17:08 干it的小张 阅读(993) 评论(0) 推荐(0)
摘要:1、socket服务端.py import socketsk = socket.socket()sk.bind(("127.0.0.1",8000))sk.listen()while True: conn,addr = sk.accept() data = conn.recv(1024) # pri 阅读全文
posted @ 2019-12-11 17:06 干it的小张 阅读(341) 评论(0) 推荐(0)
摘要:事件:绑定bind和解绑unbind: $('选择器').bind('事件',function(){ // 操作 ​ }) ​ $('选择器').unbind('事件') ​ $('选择器').click(function(){ // 操作 ​ }) ​mouseenter 鼠标进入 mousele 阅读全文
posted @ 2019-12-10 16:53 干it的小张 阅读(175) 评论(0) 推荐(0)
摘要:jquery 是一个模块 一个库 js封装的一个库 导入jq <script src="jquery.js"></script> <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script> $ == Jquer 阅读全文
posted @ 2019-12-09 16:02 干it的小张 阅读(205) 评论(0) 推荐(0)