作者文章归档:陈海峰

[ FDFS文件Django配置 ]


utils文件

FDFS_storage.py

from fdfs_client.client import Fdfs_client, get_tracker_conf
from django.conf import settings
from django.core.files.storage import Storage
from django.utils.deconstruct import deconstructible
from django_redis import get_redis_connection
from fdfs_client.exceptions import Da

< Read more >

[ 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 >