大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
import axios from 'axios';
axios.interceptors.request.use(
config => {
let ttoken = JSON.parse(localStorage.getItem('token'));
if (ttoken !== null) {
config.headers['Authorization'] = 'Token ' + ttoken;
}
return config;
}, function (error) {
return Promise.reject(error);
}
);
axios.defaults.withCredentials = true;
Vue.prototype.$ajax = axios;
提交错误
{{ e }}
INSTALLED_APPS = [
'rest_framework',
'rest_framework.authtoken',
'corsheaders',
]
# http://www.django-rest-framework.org/api-guide/permissions/#api-reference
# rest-framework
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
# 'rest_framework.permissions.AllowAny',
'rest_framework.permissions.IsAuthenticated',
)
}
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = (
'localhost:8080',
)
APPEND_SLASH=False
from rest_framework.authtoken import views
path('api-token-auth', views.obtain_auth_token),
from .serializers import AssetSerializer
from rest_framework import permissions
from rest_framework import generics
from django.views.decorators.csrf import csrf_exempt
from rest_framework.pagination import PageNumberPagination
from django.utils.deprecation import MiddlewareMixin
class StandardResultsSetPagination(PageNumberPagination):
page_size = 2
page_size_query_param = 'page'
max_page_size = 1000
class DisableCSRFCheck(MiddlewareMixin):
def process_request(self, request):
setattr(request, '_dont_enforce_csrf_checks', True)
class AssetList(generics.ListCreateAPIView,DisableCSRFCheck):
queryset = AssetLoginUser.objects.all()
serializer_class = AssetSerializer
permission_classes = (permissions.IsAuthenticated,)
pagination_class = StandardResultsSetPagination
class AssetDetail(generics.RetrieveUpdateDestroyAPIView,DisableCSRFCheck):
queryset = AssetLoginUser.objects.all()
serializer_class = AssetSerializer
permission_classes = (permissions.IsAuthenticated,)
pagination_class = StandardResultsSetPagination
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网站的建设创新互联专注网站定制,经验丰富,不做模板,主营网站定制开发.小程序定制开发,H5页面制作!给你焕然一新的设计体验!已为成都PE包装袋等企业提供专业服务。