上一页 1 2 3 4 5 6 7 ··· 15 下一页
摘要: @admin.register(Goods) class GoodsAdmin(admin.ModelAdmin): list_display = ('id', 'name', 'create_time') fieldsets = ( ('1.商品基本信息', { 'fields': ('name' 阅读全文
posted @ 2022-07-31 21:23 _Q 阅读(429) 评论(0) 推荐(0) 编辑
摘要: # models.py class Test(models.Model): goods = models.ManyToManyField(to=Goods) views.py def IndexView(request): obj = Test() obj.goods.set([1, 2, 3, 4 阅读全文
posted @ 2022-07-31 21:17 _Q 阅读(215) 评论(0) 推荐(0) 编辑
摘要: # 效果 # 代码 @admin.register(ModelName) class ModelNameAdmin(admin.ModelAdmin): list_display = ["id", "create_time"] filter_horizontal = ["name"] 阅读全文
posted @ 2022-06-30 16:32 _Q 阅读(179) 评论(0) 推荐(0) 编辑
摘要: # 金额保留两位小数 from decimal import Decimal jine = Decimal(request.data.get('jine')).quantize(Decimal("0.00")) 阅读全文
posted @ 2022-06-30 16:32 _Q 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 前提:在 settings.py 中配置了 oss ,参考:python - Django 配置阿里云 oss import os import time from django.conf import settings from django_oss_storage.backends import 阅读全文
posted @ 2022-05-31 18:48 _Q 阅读(136) 评论(0) 推荐(0) 编辑
摘要: settings.py # 直接修改访问路径 # STATIC_URL = '/static/' STATIC_URL = 'https://xxx.com/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), ) 阅读全文
posted @ 2022-03-25 17:46 _Q 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 1. app 模块下添加 test.py 文件 2. test.py from django.test import TestCase from apps.base.models import User class TestDefault(TestCase): def test_model(self 阅读全文
posted @ 2022-02-07 11:31 _Q 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 原因: MySQL里 utf8 编码最多支持3个字节, 表情却需要4个字节, 所以报错, 而 utf8mb4 编码最多支持4个字节, 所以改成 utf8mb4 后即可 解决: 1. 修改 mysql 数据库字段编码为 utf8mb4 alter table table_name modify col 阅读全文
posted @ 2021-12-13 18:05 _Q 阅读(190) 评论(0) 推荐(0) 编辑
摘要: from django_oss_storage.backends import OssMediaStorage def upload_oss_file(PostFile, FilePath): try: oss_obj = OssMediaStorage() # 返回图片路径 (oss目录下的文件路 阅读全文
posted @ 2021-12-13 17:35 _Q 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 问题: 安装过 anaconda 后还是无法使用命令 解决: 1. 找到 anaconda 的文件目录, 以我的为例就是: /home/lighthouse/anaconda3/ 2. 找到后复制, 并执行下面命令 vi ~/.bashrc 3. 在最后一行添加下面代码, anaconda目录只需要 阅读全文
posted @ 2021-12-08 15:54 _Q 阅读(1753) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 15 下一页