摘要:django 项目中 __init__.py 的代码为: 运行项目,报错 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required; you have 0.7.11.None. 解决方法: 阅读全文
posted @ 2021-01-22 20:35 Sch01aR# 阅读(9) 评论(0) 推荐(0) 编辑
摘要:views.py: from rest_framework.viewsets import GenericViewSet from rest_framework import serializers from rest_framework.pagination import PageNumberPa 阅读全文
posted @ 2021-01-21 17:31 Sch01aR# 阅读(13) 评论(0) 推荐(0) 编辑
摘要:urls.py: from django.urls import path, re_path from drf import views urlpatterns = [ path('render/', views.RenderView.as_view()), ] views.py: from res 阅读全文
posted @ 2021-01-20 22:31 Sch01aR# 阅读(17) 评论(0) 推荐(0) 编辑
摘要:urls.py: from django.urls import path, re_path from drf import views urlpatterns = [ path('view/', views.TestView.as_view({"get": "list"})), ] views.p 阅读全文
posted @ 2021-01-20 21:08 Sch01aR# 阅读(16) 评论(0) 推荐(0) 编辑
摘要:GenericAPIView: 源码: class GenericAPIView(views.APIView): queryset = None serializer_class = None lookup_field = 'pk' lookup_url_kwarg = None filter_ba 阅读全文
posted @ 2021-01-20 18:52 Sch01aR# 阅读(18) 评论(0) 推荐(0) 编辑
摘要:可以在 settings.py 中设置每页显示的数据数量 REST_FRAMEWORK = { "PAGE_SIZE": 2, # 每页显示 2 条内容 } views.py: from rest_framework import serializers from rest_framework.pa 阅读全文
posted @ 2021-01-20 15:57 Sch01aR# 阅读(16) 评论(0) 推荐(0) 编辑
摘要:可以在 settings.py 中设置每页的大小 REST_FRAMEWORK = { "PAGE_SIZE": 2, # 每页显示 2 条内容 } views.py: from rest_framework import serializers from rest_framework.pagina 阅读全文
posted @ 2021-01-20 15:40 Sch01aR# 阅读(14) 评论(0) 推荐(0) 编辑
摘要:settings.py 中设置每页的大小 REST_FRAMEWORK = { "PAGE_SIZE": 2, # 每页显示 2 条内容 } view.py: from rest_framework import serializers from rest_framework.pagination 阅读全文
posted @ 2021-01-20 00:20 Sch01aR# 阅读(8) 评论(0) 推荐(0) 编辑
摘要:views.py: # 自定义规则 class TestValidator(object): def __init__(self, base): self.base = base def __call__(self, value): # 规则明细 if not value.startswith(se 阅读全文
posted @ 2021-01-19 21:16 Sch01aR# 阅读(31) 评论(0) 推荐(0) 编辑
摘要:views.py: from rest_framework.views import APIView from rest_framework import serializers from django.shortcuts import HttpResponse class UserGroupSer 阅读全文
posted @ 2021-01-19 20:22 Sch01aR# 阅读(10) 评论(0) 推荐(0) 编辑