上一页 1 2 3 4 5 6 ··· 23 下一页
摘要: 假设我们有需要导出成excel的数据列表cut_list cut_list = [ {'name':'boy', 'age':18, 'hobby_list':['吃', '喝']}, {'name':'girl', 'age':22, 'hobby_list':['玩', '乐']} ] 确保安装 阅读全文
posted @ 2025-02-06 13:56 wellplayed 阅读(8) 评论(0) 推荐(0)
摘要: 导入依赖 from celery import chain from .task import 任务1,任务2 # 创建任务链 task_chain = chain( 任务1.si(传入的参数), 任务2.si(XXX) ) # 调用任务链,实现先执行任务1,再执行任务2 task_chain.de 阅读全文
posted @ 2024-12-23 14:37 wellplayed 阅读(121) 评论(0) 推荐(0)
摘要: 下面的示例主要运用于代码层面的去重处理,不在数据库层面增加唯一键 # 导入依赖 from django.db import models from django.utils.translation import gettext_lazy as _ from rest_framework.except 阅读全文
posted @ 2024-12-23 14:20 wellplayed 阅读(10) 评论(0) 推荐(0)
摘要: 如果书写了多个信号,可能会出现互相干扰的情况。为了防止这种情况的发生,我们可以手动控制信号的断开与连接。 # 导入依赖 from django.db.models.signals import post_save from django.dispatch import receiver def di 阅读全文
posted @ 2024-12-23 11:00 wellplayed 阅读(13) 评论(0) 推荐(0)
摘要: 将序列化后的数据导出成excel格式 # 导入依赖 import io from openpyxl import Workbook # 将格式化的数据导出为excel的方法 def output_excel(data): # 创建Excel工作簿 wb = Workbook() ws = wb.ac 阅读全文
posted @ 2024-12-20 11:19 wellplayed 阅读(109) 评论(0) 推荐(0)
摘要: 表头列合并 // 需要合并的colSpan配置为合并总列数,其余被合并的列colSpan配置为0即可 { title: 'XXX', dataIndex: 'first_name', width: 80, key: 'first_name', fixed: 'left', colSpan: 2 }, 阅读全文
posted @ 2024-12-17 16:39 wellplayed 阅读(155) 评论(0) 推荐(0)
摘要: Vuex 简介 Vuex 是 Vue.js 官方的状态管理库,帮助我们在中大型应用中集中管理组件间的共享状态。它通过 state、getters、mutations 和 actions 实现响应式数据管理 Vuex 核心概念 State: 全局状态,存储应用的核心数据。 Getters: 类似于组件 阅读全文
posted @ 2024-10-15 13:50 wellplayed 阅读(1155) 评论(0) 推荐(0)
摘要: 先看一个现象: # host/signals.py @receiver(m2m_changed, sender=Vm.products.through) def on_m2m_changed(sender, instance, action, pk_set, **kwargs): do someth 阅读全文
posted @ 2024-09-25 17:34 wellplayed 阅读(24) 评论(0) 推荐(0)
摘要: 首先需要安装必备的包 pip install celery django-celery-beat 在app中注册 INSTALLED_APPS = [ # ... 'django_celery_beat', ] 创建celery.py并配置 # project/celery.py import os 阅读全文
posted @ 2024-07-12 13:59 wellplayed 阅读(75) 评论(0) 推荐(0)
摘要: 首先创建一个signals.py文件 # 假设有一个博客应用程序,每当有新文章发表时,给订阅用户发送一封邮件通知 from django.db.models.signals import post_save from django.dispatch import receiver from djan 阅读全文
posted @ 2024-07-09 14:12 wellplayed 阅读(17) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 23 下一页