常用模塊導入
# forms組件的使用
from django import forms
2 ValidationError
# modelform報錯時使用
from django.core.exceptions import ValidationError
3 mark_safe
# 標簽的轉義
from django.utils.safestring import mark_safe
4 HttpResponse, render, redirect
# Django常用操作
from django.shortcuts import HttpResponse, render, redirect
5 QueryDict
# Django的有序字典
from django.http import QueryDict
6 reverse
# Django反向生成url
from django.urls import reverse
7 transaction
# Django的事務鎖
from django.db import transaction
8 settings
# Django的配置文件
from django.conf import settings
9 JsonResponse
# Django返回Json數據
from django.http import JsonResponse
10 transaction
# Django-事務模塊
from django.db import transaction
11 Q & F
# Django-復雜搜索&條件模塊
from django.db.models import Q
from django.db.models import F
12 messages
# Django-messages組件
from django.contrib import messages
13 get_redis_connection
# Django-redis模塊
from django_redis import get_redis_connection
14 RegexValidator
# Django-forms&modelform正則驗證模塊
from django.core.validators import RegexValidator
常用報錯導入
1 ValidationError
# Django-forms&modelform字段報錯返回數據
from django.core.exceptions import ValidationError
rest_framework模塊
1 APIView
# 視圖繼承的父類
from rest_framework.views import APIView
2 Response,Request
# 返回數據類
from rest_framework.response import Response
from rest_framework.request import Request
3 BaseAuthentication
# DRF認證類
from rest_framework.authentication import BaseAuthentication
4 BasePermission
# DRF權限類
from rest_framework.permissions import BasePermission
5 SimpleRateThrottle
# DRF限流類
from rest_framework.throttling import BaseThrottle, SimpleRateThrottle
6 serializers
# DRF序列化器
from rest_framework import serializers
1
1
1
rest_framework異常報錯
1 AuthenticationFailed
# DRF認證類拋出異常
from rest_framework.exceptions import AuthenticationFailed