zoukankan      html  css  js  c++  java
  • Django 第一天

    配置urls导包

      from django.urls import path 

      from . import views

      urlpatterns=[

        path('xxx/',views.xxx)

      ]

    配置views导包

      from django.shortcuts import render

      from django.http import HttpResponse

      

        

    修改urls内容,方便跳转

      from django.contrib import admin

      from django.urls import path,include

      urlpatterns = [

        path('admin/',admin.site.urls),

        path('/',include('polls.urls)),

    ]

    创建app:python mange.py startapp 文件名

    跨域请求配置

      INSTALLED_APPS =[

      添加 ‘corsheaders’ ]

      MIDDLEWARE = [ 

      注释掉 ‘django.middleware.csrf.CsrfViewMiddleware’

      再添加‘corsheaders.middleware.CorsMiddleware’

      

      末尾添加:

      CORS_ALLOW_CREDENTIALS = True

      CORS_ORIGIN_ALLOW_ALL = True
      CORS_ORIGIN_WHITELIST = ()
      CORS_ALLOW_METHODS = (
      'DELETE',
      'GET',
      'OPTIONS',
      'PATCH',
      'POST',
      'PUT',
      'VIEW',
      )

      CORS_ALLOW_HEADERS = (
      'XMLHttpRequest',
      'X_FILENAME',
      'accept-encoding',
      'authorization',
      'content-type',
      'dnt',
      'origin',
      'user-agent',
      'x-csrftoken',
      'x-requested-with',
      'Pragma',
      )
  • 相关阅读:
    上传文件,经过Zuul,中文文件名乱码解决办法
    Spring Cloud Sleuth进阶实战
    如何在IDEA启动多个Spring Boot工程实例
    深入理解Zuul之源码解析
    深入理解Hystrix之文档翻译
    Spring 之BeanFactory(转)
    spring之BeanFactoryAware接口
    ExecutorService线程池
    POJO
    newInstance 与new的区别
  • 原文地址:https://www.cnblogs.com/guohad/p/12070057.html
Copyright © 2011-2022 走看看