[ Django-JWT令牌 ]


JWT文档参考

安装

pip install djangorestframework-simplejwt

默认官方提供的三个接口

from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
    TokenVerifyView
)

urlpatterns = [
    ...
    # 通过获取用户传过来的username.pwd, 验证通过返回refresh, access
    path('api/token/', TokenObtain

< Read more >

[ DRF-ModelsViewSet基本用法 ]


一. 视图

class AccountViewSet(viewsets.ModelViewSet):
    queryset = Article.objects.all()
    serializer_class = ArticleSerializers

    # 一. 重写获取queryset的方法
    def get_queryset(self):
        ...
        1. 直接获取self.queryset
        2. 判断是否是queryset类型
        3. 返回queryset

    # 二. 重写获取单个实例的方法
    

< Read more >

[ Vue3-组件传参-监控 ]


Vue3组件使用, watch监控组件参数

1. 父组件

  • 传给子组件的数据类型为ref
  • 而且前面要写v-model:才是<父组件>-<子组件>数据双向传递

xxx.vue

<template>
    <notebookmain v-model:editor_content="editor_content_ref" v-model:editor_title="editor_title_ref"></notebookmain>
</template>

<script>

< Read more >

[ django DRF序列化器 ]


安装模块

  • conda install djangorestframework
  • conda install markdown
  • conda install django-filter

一. 配置settings.py注册APPS

- INSTALLED_APPS = [
    ...
     'rest_framework',
    ]

二. 如果打算使用可浏览的API,还需要添加PEST框架的登录和注销视图,将以下内容添加到根目录urls.py文件

urlpatterns = [
    ...
path('api-auth/', include(&

< Read more >

[ django跨域网络配置 ]


解决跨域问题(第三方)

  • 安装模块
    • pip install django-cors-headers
  • 在settings.py的apps里注册
    • INSTALLED_APPS = ( 'corsheaders'
    • )
  • 在settings.py里添加中间件
    • MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', #添加这个 'django.middleware.common.CommonMiddleware', # 这个是原本就存在的 ]
  • 设置settings.py的ALLOWED_HOSTS

< Read more >

[ 记单词 ]


数据库单词

  • 数据库插入数据
    • insert into ou(id,name) values(1,'chf')
  • 数据库修改数据
    • update ou set name='ozj' where name='chf'
  • 数据库删除数据
    • delete from ou where name='ozj'
  • 数据库查询数据
    • selecr * from ou 查询所有
    • selecr * from ou name='ozj' 查询单个
  • 切换数据库
    • use+数据库名
  • 查询数据库/表
    • show database 数据库
    • show table 表

linux系统命令

  • 关机
    • poweroff

< Read more >

[ websocket安装模块错误 ]


配置bing-chat项目时

Bing-Chat项目GITHUB

1. 克隆到本地 git clone xxx

2. 使用Dockerfile文件生成Python镜像文件

# 改良版(未测试)
FROM python:3
ENV PYTHONUNBUFFERED 1
WORKDIR /usr/src/app

RUN apt-get install default-libmysqlclient-dev -y && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

COPY requirements.tx

< Read more >

[ pip下载速度慢 ]


python包管理器pip下载速度慢

清华 终端输入下面两行配置:

RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple && \
  pip config set install.trusted-host mirrors.aliyun.com

阿里

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
pip config set install.trusted-host mirrors.a

< Read more >