摘要:安装: # pip3 install apscheduler==2.1.2 使用:在Django项目settings.py同级urls.py from apscheduler.scheduler import Scheduler sched = Scheduler() @sched.interval
阅读全文
摘要:启动服务 redis-server 启动客户端 redis-cli # 哈希常用操作 存hash类型键值对 hset aa 11 111 取hash类型键值对 hget aa 11 获取hash下所有键值对 hgetall aa 删除hash键值对 hdel aa 11 # 列表常用操作 从右边推入
阅读全文
摘要:xadmin:是django的一套优于admin的后台管理系统,不仅提供了可观性更高的UI界面,还封装了基于模型类的CURD,支持过滤查询,多种形式的数据导出,还有很多方便易用的小插件。它的缺点是,如果有一些自定义的功能,页面展示部分和权限控制部分可能需要改底层代码,不是特别方便我的场景是,一对多的
阅读全文
摘要:1、models.AutoField 自增列 = int(11) 如果没有的话,默认会生成一个名称为 id 的列,如果要显示的自定义一个自增列,必须将给列设置为主键 primary_key=True。2、models.CharField 字符串字段 单行输入,用于较短的字符串,如要保存大量文本, 使
阅读全文
摘要:我们可以使用echo_supervisord_conf命令得到supervisor配置模板,打开终端执行如下Linux shell命令: # echo_supervisord_conf > supervisord.conf 该命令输出文件到当前目录下(当然,你也可以指定绝对路径到具体位置),文件名为
阅读全文
摘要:# -*- coding:utf-8 -*- from django.shortcuts import render from django.http import JsonResponse,HttpResponse from django.views.generic import Viewimpo
阅读全文
摘要:钉钉API文档:https://ding-doc.dingtalk.com/doc#/serverapi2/skn8ld 钉钉有回调事件流程,有哪些回调?比如:通讯录回调、审批回调等等,拿通讯录回调来说,就是当你公司组织架构发生变动时,会自动触发你自己注册的回调地址,然后根据回调信息做一些自定义的处
阅读全文
摘要:from django.db.models import Max,Avg,F,Q,Min,Count,Sum this_year = datetime.datetime.now().year this_year_data = UserPrice.objects.filter(year=this_ye
阅读全文
摘要:from stat import S_ISDIR as isdir try: private_key = paramiko.RSAKey.from_private_key_file('/root/.ssh/id_rsa') t = paramiko.Transport((ip, 22)) t.con
阅读全文
摘要:方法一: 使用HttpResonse 下面方法从url获取file_path, 打开文件,读取文件,然后通过HttpResponse方法输出。 import os from django.http import HttpResponse def file_download(request, file
阅读全文
摘要:在使用django框架时,需要在settings中将时区设置成上海 TIME_ZONE = 'Asia/Shanghai' USE_TZ = True 手动方式: from django.utils import timezone # print(timezone.localtime(i.creat
阅读全文
摘要:恢复内容开始 1、首先什么是双向选择器,上图 类似这样的一个可以穿梭相互选择的选择器,实现方法:html+jquery+django django-models.py # 用户组使用了Django自带的group表 from django.contrib.auth.models import Use
阅读全文
摘要:首先在同步两篇之前写过的博客,可能能用得到 1、https://www.cnblogs.com/lutt/p/10893192.html2、https://www.cnblogs.com/lutt/p/10895317.html在上述操作的过程中,在执行命令:scrapyd-deploy时遇报错:
阅读全文
摘要:在执行python3 manage.py migrate时报错:操作错误,某库未给某用户授权 django.db.utils.OperationalError: (1044, "Access denied for user 'xxx'@'localhost' to database 'xxx'")
阅读全文
摘要:1.首先注册应用,获取 appkey、appsecret api_url = "https://oapi.dingtalk.com/gettoken?appkey=%s&appsecret=%s"%(appkey,appsecret) def get_token(): # try: res = re
阅读全文
摘要:Django数据库迁移报错:1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='" 原因是在创建数据库时没有指定编码utf8 正确
阅读全文
摘要:在执行python3 manage.py migrate时出现以下错误 ?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default' HINT: MySQL's Strict Mode fixes man
阅读全文
摘要:1.首先在项目同名目录下建一个celery.py from __future__ import absolute_import import os from celery import Celery from datetime import timedelta from kombu import Q
阅读全文
摘要:import requests import json try: import cookielib except: import http.cookiejar as cookielib # 使用urllib2请求https出错,做的设置 import ssl context = ssl._creat
阅读全文
摘要:python3 manage.py makemigrations # 生成数据库迁移文件 python3 manage.py migrate # 迁移数据库 简简单单两条命令就完成了django的数据库迁移 但是今天一天的时间都耽误在这了,一点都不夸张的那种,,早上去公司讨论需求之后,研究了一下需要
阅读全文