上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 71 下一页
摘要: 方法一 系统: 1)AllowAny:允许所有用户,校验方法直接返回True 2)IsAuthenticated:只允许登录用户 必须request.user和request.user.is_authenticated都通过 3)IsAuthenticatedOrReadOnly:游客只读,登录用户 阅读全文
posted @ 2020-12-24 19:51 不带R的墨菲特 阅读(216) 评论(0) 推荐(0)
摘要: 模型: class LogisticQuerySet(QuerySet): def delete(self): self.update(is_delete=True) class BookManager(models.Manager): _queryset_class = LogisticQuery 阅读全文
posted @ 2020-12-17 19:28 不带R的墨菲特 阅读(433) 评论(0) 推荐(0)
摘要: class People(object): passdef score(self,attr): self.attr=attrPeople.score=score if __name__ == '__main__': p=People() p.score("11") print(p.attr)方式二: 阅读全文
posted @ 2020-12-17 15:53 不带R的墨菲特 阅读(85) 评论(0) 推荐(0)
摘要: 对象delete():调用的django.model.db.base 模块delete 方法 queryset的delete调用的 django.db.models.query QuerySet类的delete方法: 模型: class LogisticQuerySet(QuerySet): def 阅读全文
posted @ 2020-12-16 20:41 不带R的墨菲特 阅读(743) 评论(0) 推荐(0)
摘要: 1。模型 图书和作者是多对多关系 class Book(models.Model): book_name=models.CharField(max_length=40) price=models.DecimalField(max_digits=4,decimal_places=2) publish= 阅读全文
posted @ 2020-12-15 20:46 不带R的墨菲特 阅读(1380) 评论(0) 推荐(0)
摘要: 前提概要: 一对多模型: 编写模型类: class AppleModel(models.Model): id=models.AutoField(primary_key=True) app_name=models.CharField(max_length=50) class Meta: db_tabl 阅读全文
posted @ 2020-12-03 21:19 不带R的墨菲特 阅读(439) 评论(1) 推荐(0)
摘要: 先上源码: 1.注释解释是根据**kwargs去查,如果对象查到就更新一个对象,否则就创建一个对象 此外这里引用到行锁概念,阻塞当前查询对象的更新直到update_or_create() 调用save()方法结束; 整个操作是在一个事务里执行证明是可回滚的 源码select_for_update方法 阅读全文
posted @ 2020-11-30 15:37 不带R的墨菲特 阅读(276) 评论(1) 推荐(0)
摘要: 1.安装库: pip install drf-yasg==1.20.0 2.注册app: 3.配置settings.py 同目录的urls.py路由: from django.contrib import adminfrom django.urls import pathfrom django.ur 阅读全文
posted @ 2020-11-29 17:13 不带R的墨菲特 阅读(245) 评论(2) 推荐(0)
摘要: 3、反向生成 现在数据库中创建表 CREATE TABLE `alarm_group` ( `group_name` varchar(250) NOT NULL, `group_des` blob, `members` blob, `timestamp` datetime NOT NULL, `on 阅读全文
posted @ 2020-11-28 17:59 不带R的墨菲特 阅读(206) 评论(1) 推荐(0)
摘要: class AppleModel(models.Model): id=models.AutoField(primary_key=True) app_name=models.CharField(max_length=50) class Meta: db_table='tbl_apple' class 阅读全文
posted @ 2020-11-28 17:43 不带R的墨菲特 阅读(230) 评论(0) 推荐(0)
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 71 下一页