docker搭建elasticsearch下载镜像# 下载镜像 docker pull delron/elasticsearch-ik:2.4.6-1.0 加载配置文件配置的目录: /root/elastic_config/config elasticsearch.yml network.host 需要更新为 本机IP # ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable def...

阅读全文>>

总忘记,记录下吧 on_delete 的六种操作 1. models.CASCADE: 将定义有外键的模型对象同时删除 ,django模板的默认操作 2. model.PROTECT: 阻止上面的删除操作,但是弹出ProtectedError异常 3. models.SET_NULL: 将外键字段设为null,只有当字段设置了null=True时,方可使用该值 4. models.SET_DEFAULT: 将外键字段设为默认值,只有当字段设置了default参数时,方可使用 5. models.DO_N...

阅读全文>>

0x01 linux配置#Linux下运行celery的命令是这个 celery -A djangoProject1 worker --loglevel=INFO celery -A celery_tasks.main worker -l info 0x02 windows上的配置celery -A djangoProject1 worker --concurrency=4 --loglevel=INFO -P threads celery -A celery_tasks.main worker --concurrency=4 --loglevel=INFO -P threads ...

阅读全文>>

表结构 商品表店铺表收藏关系表人员表 人收藏商品,人收藏店铺, 收藏的关系保存在 收藏关系表中 models.pyfrom django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType from django.db import models # Create your models here. from accounts.models import Stude...

阅读全文>>

base_jinja2.py#coding:utf-8 from jinja2 import Environment # jinja2的虚拟环境 from django.contrib.staticfiles.storage import staticfiles_storage # django的一些依赖 from django.urls import reverse # urls需要和jinja进行一些配置 def environment(**options): env = Environment(**options) # 把一些配置文件添加进去 ...

阅读全文>>

win配置打开Postgresql配置文件,如:C:\Program Files\PostgreSQL\14\data\postgresql.conf log_directory = 'log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, log_statement = 'all # 关键点 处理win10 乱码打开配置文件 ~datapostgresql.conf 修改 lc_messages = 'C' 修改日志格式log_filename = 'postgresql-%Y-...

阅读全文>>

安装 swaggerpip install drf_yasg setting.py 添加 swaggerINSTALLED_APPS = [ .... 'drf_yasg', ] 总路由配置 url.py# 配置 swagger from drf_yasg.views import get_schema_view from drf_yasg import openapi from rest_framework import permissions schema_view = get_schema_view( openapi.Info( ...

阅读全文>>

一般的安装步骤1 安装依赖库pip3 install django-debug-toolbar 2 settings.py中 将 debug_toolbar 添加到 INSTALL_APPS 中INSTALLED_APPS = [ 'django.contrib.staticfiles', … 'debug_toolbar',# 注册debug_toolbar,放在django.contrib.staticfiles后面 ] 3 settings.py中 在中间件中加入DebugToolbarMiddlewareMIDDLEWARE = [ # ... '...

阅读全文>>

1 安装依赖包pip install coreapi 2 seting.py的文件配置REST_FRAMEWORK = { 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema', } 3 url的配置from django.conf.urls import url from rest_framework.documentation import include_docs_urls url(r'^docs/', include_docs_urls(title='接口文档')), 4 访问http://127.0.0....

阅读全文>>

setting添加配置 AUTHENTICATION_BACKENDS = ( 'users.views.CustomBackend', # 'django.contrib.auth.backends.ModelBackend', ) users.views.CustomBackendfrom django.contrib.auth import get_user_model from django.contrib.auth.backends import ModelBackend, BaseBackend from django.db.models import...

阅读全文>>

报错的测试$data = rtrim("揭西县","县"); print($data); 返回结果异常 处理汉字编码的问题$tmp = mb_substr("揭西县",0,-1*mb_strlen("县")); print($tmp); 总结 线上的一个报错,汉字编码的问题,记录下吧,遇到汉字记得使用 mb_func类的函数

阅读全文>>

配置文件 # sql日志记录 LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%(levelname)s...

阅读全文>>

redis_db 连接数据库 import redis try: pool = redis.ConnectionPool( host="localhost", port=6379, password="123456", db=0, max_connections=200 ) except Exception as e: print(e) thread 多线程操作 from concurrent.futures import ThreadPoolExecutor from redis_db import pool impo...

阅读全文>>

<?php // phpinfo(); class Week { function get_week_all($year) { $whole_week = $this->get_big_week($year);//获取最大周数 $str = ''; for ($i = 1; $i <= $whole_week; $i++) { $str .= $i . ','; } $str_arr = explode(',', rtrim($...

阅读全文>>