解决django前端使用iframe标签报错127.0.0.1 refused to connect.

解决方法

  1. settings.py中配置ALLOWED_HOSTS,结果如下:

    ALLOWED_HOSTS = ['*']
    
  2. settings.py中配置MIDDLEWARE,注释XFrameOptionsMiddleware,结果如下:

    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        # 'django.middleware.clickjacking.XFrameOptionsMiddleware', # 注释这一条
    ]
    
上一篇:ubantu14.04.4配置opencv3.4.13)


下一篇:django框架配置文件说明