2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Djangoの開発環境でiframeが表示されない(127.0.0.1から接続を拒否される)

Last updated at Posted at 2020-05-21

DjangoのTemplatesに置いたHTMLファイル内に<iframe>を利用してPDF等を表示させようとすると表示がされない。
(Chromeからは127.0.0.1 refused to connect.と言われる。)

これはclickjackingに引っかかっているためと考えられるので、settings.pyに以下の設定をすることで解決できた。

X_FRAME_OPTIONS = 'ALLOW'

※前提としてsettings.pyに以下Middlewareが入っていること
MIDDLEWARE = [
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?