会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
去遇见最好的自己
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
下一页
2019年12月6日
python中几个小方法
摘要: # 解压赋值 a,b = (1,2) print(a,b) # 1 2 # 交叉赋值 a = 1 b = 2 a,b = b,a print(a,b) # 2 1 # 按指定条件给字典排序 test = {'a':1,'b':3,'c':2} res = dict(sorted(test.items
阅读全文
posted @ 2019-12-06 09:30 去遇见最好的自己
阅读(159)
评论(0)
推荐(0)
2019年12月4日
python中几个常用函数
摘要: # zip 将两个列表,对应位置的值拼接成元组,最后结果是一个列表套元组,注:不对应的值,会被舍弃. l1 = [1,1,3,6,7] l2 = [1,2,3,4] print(list(zip(l1,l2))) # [(1, 1), (2, 2), (3, 3), (6, 4)] # filter
阅读全文
posted @ 2019-12-04 15:26 去遇见最好的自己
阅读(213)
评论(0)
推荐(0)
2019年11月19日
ajax上传图片
摘要: 修改头像 ajax上传图片,必须创建FormDate(),然后把图片加进去. ajax上传图片 $('#id_set_avatar_submit').click(function () { avatar_img = $('#id_avatar')[0].files[0]; var formData
阅读全文
posted @ 2019-11-19 21:55 去遇见最好的自己
阅读(191)
评论(0)
推荐(0)
2019年11月18日
django数据库迁移报错:System check identified some issues:
摘要: from django.db import models from django.contrib.auth.models import AbstractUser # Create your models here. # 用户表 class UserInfo(AbstractUser): phone
阅读全文
posted @ 2019-11-18 21:37 去遇见最好的自己
阅读(846)
评论(0)
推荐(0)
2019年11月17日
关于:自关联!!!!
摘要: # 在ORM中设置自关联字段 class Comment(models.Model): user = models.ForeignKey(to='UserInfo') article = models.ForeignKey(to='Article') content = models.CharFie
阅读全文
posted @ 2019-11-17 22:59 去遇见最好的自己
阅读(491)
评论(0)
推荐(0)
解决ORM错误:django.db.utils.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails
摘要: # 修改settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'test', 'HOST':'127.0.0.1', 'PORT':3306, 'USER':'root', 'PASS
阅读全文
posted @ 2019-11-17 21:22 去遇见最好的自己
阅读(3170)
评论(0)
推荐(1)
2019年11月10日
DRF自定义认证类
摘要: # 自定义认证类class Authtication(object): # 自定义认证方法 def authenticate(self, request): # 查看前端传过来的数据是否有token token = request._request.GET.get('token') # 查询数据库用
阅读全文
posted @ 2019-11-10 10:08 去遇见最好的自己
阅读(418)
评论(0)
推荐(0)
2019年11月9日
深浅拷贝
摘要: 深浅拷贝 深浅copy 先问问大家,什么是拷贝?拷贝是音译的词,其实他是从copy这个英文单词音译过来的,那什么是copy? copy其实就是复制一份,也就是所谓的抄一份。深浅copy其实就是完全复制一份,和部分复制一份的意思。 1,先看赋值运算。 l1 = [1,2,3,['jason','ego
阅读全文
posted @ 2019-11-09 10:53 去遇见最好的自己
阅读(136)
评论(0)
推荐(0)
2019年11月8日
Django自定义CBV
摘要: CBV,基于反射实现根据请求方式的不同,执行不同的方法. 查看view源码,使用反射getattr(self, request.method.lower(), self.http_method_not_allowed),调用对方法 原理: url->view->dispatch->执行get,pos
阅读全文
posted @ 2019-11-08 20:50 去遇见最好的自己
阅读(280)
评论(0)
推荐(0)
2019年11月7日
两种无限递归菜单
摘要: # 第一种 res_list = [ {'cat_id':1,'name':'北京','parent_id':0}, {'cat_id':2,'name':'杭州','parent_id':0}, {'cat_id':3,'name':'海淀区','parent_id':1}, {'cat_id':
阅读全文
posted @ 2019-11-07 22:08 去遇见最好的自己
阅读(388)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
下一页
公告