会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Zeng
Think Twice, Code Once
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
13
14
15
16
17
18
19
20
21
···
23
下一页
2023年12月20日
APIView源码分析
摘要: 1.和CBV源码执行流程相似,请求来了先走路由层: path('books/', views.BookView.as_view()) 2.走APIView的as_view方法,代码如下: @classmethod def as_view(cls, **initkwargs): view = supe
阅读全文
posted @ 2023-12-20 15:08 wellplayed
阅读(18)
评论(0)
推荐(0)
2023年12月13日
使用富文本编辑器KindEditor上传图片,一直显示:上传中,请稍后... 的解决办法
摘要: 问题详细: 在使用KindEditor上传图片时,后端已经接收到了,但前端仍在加载 如下图: 解决办法: 方法一: 在配置文件中书写以下代码: X_FRAME_OPTIONS = 'ALLOWALL' 方法二: 注释中间件: 'django.middleware.clickjacking.XFram
阅读全文
posted @ 2023-12-13 19:05 wellplayed
阅读(321)
评论(1)
推荐(1)
2023年12月8日
forms组件
摘要: forms组件的作用 1 渲染页面 2 校验数据 3 渲染错误 forms组件的使用方法 书写: 首先需要新建一个py文件,并导入模块 from django import forms 再书写一个类继承forms.Form class MyRegForm(forms.Form): 书写字段: use
阅读全文
posted @ 2023-12-08 08:56 wellplayed
阅读(26)
评论(0)
推荐(0)
2023年12月7日
captcha模块——生成图片验证码
摘要: 安装 captcha 库 pip install captcha 基本使用方法(生成图片验证码) import captcha from captcha.image import ImageCaptcha # 设置图片宽高 image = ImageCaptcha(width=200, height
阅读全文
posted @ 2023-12-07 16:29 wellplayed
阅读(1158)
评论(0)
推荐(0)
项目规范——requirements.txt
摘要: 在python项目中,需要有一个txt文件requirements.txt,里面面书写当前项目中所有的依赖 书写规范如下: requirements.txt 内 django==3.2.20 pillow mysqlclient 以后使用项目时输入以下命令: pip install -r requi
阅读全文
posted @ 2023-12-07 14:46 wellplayed
阅读(167)
评论(0)
推荐(0)
2023年12月5日
数据库的几种连表方式详解
摘要: 数据库主要有五种连表方式 首先需要准备两张表: 图书表 book id name price publish_id 1 西游记 33 1 2 红楼梦 56 1 3 三国演义 66 2 4 西厢记 55 6 出版社表 publish id name addr 1 北京出版社 北京 2 南京出版社 南京
阅读全文
posted @ 2023-12-05 15:01 wellplayed
阅读(434)
评论(0)
推荐(0)
2023年12月1日
loguru模块——日志模块的使用
摘要: 安装 pip install loguru 1、输出日志 from loguru import logger logger.debug("这是一条debug日志") 终端执行后出现带颜色的日志: 2、输出到文件 from loguru import logger logger.add("file_{
阅读全文
posted @ 2023-12-01 17:29 wellplayed
阅读(152)
评论(0)
推荐(0)
扩展auth_user表
摘要: 扩展auth_user表 方法一: from django.contrib.auth.models import User # 第一种: 建立一对一外键关系 (不推荐) class UserDetail(models.Model): phone = models.BigIntegerField()
阅读全文
posted @ 2023-12-01 15:40 wellplayed
阅读(44)
评论(0)
推荐(0)
2023年11月30日
Django四件套在响应头中放入数据的方法
摘要: HttpResponse 方法一: return HttpResponse('ok',headers={'xxx':'xxx'}) 方法二: obj = HttpResponse('ok') obj['yyy'] = 'yyy' # 像字典一样放入,最终会放在http的响应头中 return obj
阅读全文
posted @ 2023-11-30 15:19 wellplayed
阅读(23)
评论(0)
推荐(0)
查看一个 '函数' 到底是【函数】还是【方法】
摘要: 需要用到FunctionType和MethodType from types import FunctionType, MethodType 准备测试用代码 写一个函数: def add(): pass 写一个类: class Person: def run(self): pass @classme
阅读全文
posted @ 2023-11-30 15:07 wellplayed
阅读(17)
评论(0)
推荐(0)
上一页
1
···
13
14
15
16
17
18
19
20
21
···
23
下一页
公告