Browse Source

'新增N个注释'

DYaiu 4 years ago
parent
commit
ed68309ba8
2 changed files with 3 additions and 0 deletions
  1. 2 0
      my_project/settings.py
  2. 1 0
      workreport/views.py

+ 2 - 0
my_project/settings.py

@@ -122,8 +122,10 @@ USE_TZ = True
 STATIC_URL = '/static/'
 
 REST_FRAMEWORK = {
+    # 设置分页默认类  ?limit=?&offset=?    更习惯使用 PageNumberPagination
     'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
     'PAGE_SIZE': 3,
+    # 设置过滤默认类  SearchFilter搜索类、OrderingFilter排序类
     'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
     'DEFAULT_PERMISSION_CLASSES': ['rest_framework.permissions.IsAuthenticated'],
     'DEFAULT_AUTHENTICATION_CLASSES': (

+ 1 - 0
workreport/views.py

@@ -26,6 +26,7 @@ class DailyReportViews(APIView):
 class ReportViews(ModelViewSet):
     queryset = DailyReport.objects.all()
     serializer_class = DailyReportSerializer
+    # search_fields '^'开始搜索。'='完全匹配。'@'全文搜索。(当前仅支持Django的MySQL后端。)'$'正则表达式搜索。
     filter_fields = {'title': ['exact']}