随笔分类 -  Django

摘要:from django.db import models # Create your models here. class DictConfig(models.Model): """ 字典表 """ id = models.AutoField(primary_key=True) dictype= m 阅读全文
posted @ 2022-08-27 11:27 **绵绵羊** 阅读(100) 评论(0) 推荐(0) 编辑
摘要:原代码: class DictConfig(models.Model): """ 字典表 """ id = models.AutoField(primary_key=True) dictype= models.CharField("类型", max_length=30, unique=True) d 阅读全文
posted @ 2022-08-25 19:34 **绵绵羊** 阅读(57) 评论(0) 推荐(0) 编辑
摘要:源码示例: from rest_framework import serializers from set.models import Set class SetSerializers(serializers.ModelSerializer): """ 配置信息序列化 """ product_id 阅读全文
posted @ 2022-03-17 13:44 **绵绵羊** 阅读(795) 评论(0) 推荐(1) 编辑
摘要:在django中,默认配置的数据库是 sqlite3 # Database # https://docs.djangoproject.com/en/2.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db. 阅读全文
posted @ 2021-04-12 19:29 **绵绵羊** 阅读(1043) 评论(0) 推荐(0) 编辑
摘要:models.py # 创建产品表 class Product(models.Model): productName = models.CharField('产品名称', max_length=64) # 产品名称 productDesc = models.CharField('产品描述', max 阅读全文
posted @ 2021-02-23 19:40 **绵绵羊** 阅读(485) 评论(0) 推荐(1) 编辑
摘要:执行命令 python manage.py makemigrations时抛出以下错误 Traceback (most recent call last): File "D:\Program Files\Python\Python37-32\lib\site-packages\django\db\b 阅读全文
posted @ 2021-02-23 19:33 **绵绵羊** 阅读(1343) 评论(0) 推荐(0) 编辑
摘要:执行python manage.py makemigrations时出现以下错误 D:\autotestplat>python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 21, 阅读全文
posted @ 2021-02-23 18:30 **绵绵羊** 阅读(2397) 评论(0) 推荐(0) 编辑
摘要:BugDeserializer 对象中没有 ‘_meta’ 属性,定位到调用BugDeserializer位置, 用于序列化时,将模型类对象传入instance参数 在update时,数据传入有误,更改如下: 再次run,运行正常 阅读全文
posted @ 2020-09-11 18:01 **绵绵羊** 阅读(303) 评论(0) 推荐(0) 编辑
摘要:程序执行后一直提示ValueError: HTTP status code must be an integer from 100 to 599. 遍历代码一切正常,然后开始调试代码,找出获取数据有问题,直接到except中,按理来讲也只是报{code=10020, msg='param error 阅读全文
posted @ 2020-09-11 17:32 **绵绵羊** 阅读(1193) 评论(0) 推荐(0) 编辑
摘要:在调用添加接口时,一值失败,调试后发现传入的数据并没有问题,但是数据验证时一直返回False,此时使用 serializer.error_messages查看,所返回如下问题: 再往上看显示: 发现序列化器id字段上的验证器显式强制执行唯一性约束,进入model中查看id字段定义 修改代码如下: 执 阅读全文
posted @ 2020-09-09 10:53 **绵绵羊** 阅读(2298) 评论(0) 推荐(0) 编辑
摘要:swagger已配置OK,但发送POST请求时一直显示数据格式错误,怪异。。。。 经过各种查找资料,才发现setting.py文件中缺少配置 配置完成后重启服务,再次尝试发送POST请求,不会再报格式错误了。。 阅读全文
posted @ 2020-09-03 15:07 **绵绵羊** 阅读(701) 评论(0) 推荐(0) 编辑
摘要:在使用jmeter调试接口时,提示pymysql.err.ProgrammingError: (1146, "Table 'autoplatform.webcasestepinfo' doesn't exist"错误,显示在数据时webcasestepinfo表不存在/(ㄒoㄒ)/~~ 直接进入数据 阅读全文
posted @ 2020-09-03 14:45 **绵绵羊** 阅读(3961) 评论(0) 推荐(0) 编辑
摘要:swagger好处不多说,直接上配置步骤 1、安装swagger pip install django-rest-swagger 2、将swagger配置到setting.py文件中 3、在主url.py中配置接口文档路径 代码解析: from rest_framework.schemas impo 阅读全文
posted @ 2020-09-02 15:15 **绵绵羊** 阅读(2110) 评论(0) 推荐(0) 编辑
摘要:在启动服务时报django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: rest_framework_swagger错误 错误解释:应用程序标签不是唯一的,重复的rest_fr 阅读全文
posted @ 2020-09-02 14:26 **绵绵羊** 阅读(818) 评论(0) 推荐(0) 编辑
摘要:代码: class WebCase(models.Model): id = models.AutoField(primary_key=True) casename = models.CharField("用例名称", max_length=200) caseresult = models.Boole 阅读全文
posted @ 2020-09-01 18:07 **绵绵羊** 阅读(461) 评论(0) 推荐(0) 编辑
摘要:代码: class CaseStepAdmin(admin.ModelAdmin): list_display = ('id', 'casetep', 'casedata', 'webcase', 'stepresult', 'update_time', 'create_time') model = 阅读全文
posted @ 2020-08-31 14:14 **绵绵羊** 阅读(699) 评论(0) 推荐(0) 编辑
摘要:错误代码: class CaseStep(models.Model): id = models.AutoField(primary_key=True) casetep = models.ForeignKey(WebStepInfo, on_delete=models.CASCADE, verbose 阅读全文
posted @ 2020-08-31 14:03 **绵绵羊** 阅读(330) 评论(0) 推荐(0) 编辑
摘要:使用2.2 版本的django时,出现django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.,查了资料才知道是兼容问题 出现此类问题 方法一可删除项目根 阅读全文
posted @ 2020-05-23 17:44 **绵绵羊** 阅读(189) 评论(0) 推荐(0) 编辑
摘要:代码: def login(request): if request.POST: username = request.POST.get('username') password = request.POST.get('password') user = auth.authenticate(user 阅读全文
posted @ 2020-05-23 17:04 **绵绵羊** 阅读(251) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示