欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Django解決frame拒絕問題的方法

 更新時(shí)間:2020年12月18日 14:11:27   作者:湯圓兒2019  
這篇文章主要介紹了Django解決frame拒絕問題的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

一、home頁使用frame

template/home.html

<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<head>
  <title>自動(dòng)化測(cè)試平臺(tái)</title>
</head>

<frameset id="frame" rows="*" cols="265,*" framespacing="0" frameborder="yes" border="0">
  <frame src="../left" name="leftFrame" scrolling="auto" noresize>
  <frame src="../welcome" name="mainFrame" scrolling="NO" noresize>
</frameset>
<noframes>
  <body>
  <h1>hello</h1>
  </body>
</noframes>
</html>

二、視圖文件

AutoTestPlat/views.py

def home(request):
  return render(request, 'home.html')

def left(request):
  return render(request, 'left.html')

def welcome(request):
  return render(request, 'welcome.html')

三、urls映射文件

urlpatterns = [
  path('admin/', admin.site.urls),
  path('', views.login),
  path('login/', views.login),
  path('home/', views.home),
  path('left/', views.left),
  path('welcome/', views.welcome),
]

命令行執(zhí)行python manage.py runserver后,Chrome瀏覽器打開http://127.0.0.1:8000/home/,顯示如下圖。打開F12,報(bào)以下錯(cuò)誤。

在這里插入圖片描述

四、解決方案

在setting.py中設(shè)置:

# 解決frame跨域問題
X_FRAME_OPTIONS = 'ALLOWALL url'

到此這篇關(guān)于Django解決frame拒絕問題的方法的文章就介紹到這了,更多相關(guān)Django frame拒絕內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論