django DEBUG=False
在django的settings中. 将DEBUG 设置为False. 会出现
#python manage.py runserver 8888
CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.
#####################################################
提示DEBUG为False时,必须设置settings.ALLOWED_HOSTS .
ALLOWED_HOSTS = [
'.example.com', # Allow domain and subdomains
'.example.com.', # Also allow FQDN and subdomains
]
或者您需要设置所有的均可访问.那么可以这样设置.
ALLOWED_HOSTS = ['*']
任何用户均可以访问.
然后再访问下.恢复正常. 相关django官方文档.
https://docs.djangoproject.com/en/1.7/ref/settings/
在此引用一下.
ALLOWED_HOSTS¶ Default: [] (Empty list) A list of strings representing the host/domain names that this Django site can serve. This is a security measure to prevent an attacker from poisoning caches and password reset emails with links to malicious hosts by submitting requests with a fake HTTP Host header, which is possible even under many seemingly-safe web server configurations. Values in this list can be fully qualified names (e.g. 'www.example.com'), in which case they will be matched against the request’s Host header exactly (case-insensitive, not including port). A value beginning with a period can be used as a subdomain wildcard: '.example.com' will match example.com, www.example.com, and any other subdomain of example.com. A value of '*' will match anything; in this case you are responsible to provide your own validation of the Host header (perhaps in a middleware; if so this middleware must be listed first in MIDDLEWARE_CLASSES).
Changed in Django 1.7: In previous versions of Django, if you wanted to also allow the fully qualified domain name (FQDN), which some browsers can send in the Host header, you had to explicitly add another ALLOWED_HOSTS entry that included a trailing period. This entry could also be a subdomain wildcard:
ALLOWED_HOSTS = [
'.example.com', # Allow domain and subdomains
'.example.com.', # Also allow FQDN and subdomains
]
In Django 1.7, the trailing dot is stripped when performing host validation, thus an entry with a trailing dot isn’t required. If the Host header (or X-Forwarded-Host if USE_X_FORWARDED_HOST is enabled) does not match any value in this list, the django.http.HttpRequest.get_host() method will raise SuspiciousOperation. When DEBUG is True or when running tests, host validation is disabled; any host will be accepted. Thus it’s usually only necessary to set it in production. This validation only applies via get_host(); if your code accesses the Host header directly from request.META you are bypassing this security protection.
django DEBUG=False的更多相关文章
- Python django 404页面配置和debug=false 静态文件配置 django版本1.10.5
django设置404页面 1.设置settings文件 DEBUG = False ALLOWED_HOSTS = ['127.0.0.1', 'localhost']或者 ALLOWED_HOST ...
- 配置Django框架为生产环境的注意事项(DEBUG=False)
问题描述: Django1.10版本中框架中settings.py配置文件 配置文件settings.py配置了下面两项: DEBUG= False ALLOWED_HOSTS = ['*'] #这样 ...
- Django设置 DEBUG=False后静态文件无法加载
修改setting.py STATIC_URL = '/static/' STATIC_ROOT = 'static' ## 新增行 STATICFILES_DIRS = [ os.path.join ...
- Django设置 DEBUG=False后静态文件无法加载解决
前段时间调试一直是在Debug=True先运行的,没有什么问题.今天关闭了Debug后,出现了一个问题.就是静态文件找不到了,「img.css.js」都提示404,无法准确的访问 static 静态文 ...
- Django settings.py设置 DEBUG=False后静态文件无法加载解决
解决办法: settings.py 文件 DEBUG = False STATIC_ROOT = os.path.join(BASE_DIR,'static') #新增 urls.py文件(项目的) ...
- django 注册后台管理 在debug=true能行,在debug=false不能显示出管理标签
debug=true 下,如下图:
- 部署前准备--使用Mysql之Django Debug Toolbar安装以及配置
python -c "import django ;print(django.__path__);" 查看python的全局配置 vi /usr/local/lib/python3 ...
- Django之Django debug toolbar调试工具
一.安装Django debug toolbar调试工具 pip3 install django-debug-toolbar 如果出错命令为 pip install django_debug_tool ...
- 【Django】Django Debug Toolbar调试工具配置
正在发愁怎么调试Django,就遇到了Django Debug Toolbar这个利器. 先说遇到的问题: 网上也有教程,不过五花八门的,挨个尝试了一遍,也没有成功运行.最后终于找到问题所在: 从开发 ...
随机推荐
- kt 集合
Kotlin初探:Kotlin的集合操作符 2017年11月10日 12:40:03 笨鸟-先飞 阅读数:649 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.c ...
- Python str list to list
eg1: My csv data like this below,i wt count list nums 2018上,"['C', 'B', 'B', 'B', 'D', 'A', 'B' ...
- 1.3.8、CDH 搭建Hadoop在安装之前(端口---Apache Flume和Apache Solr使用的端口)
Apache Flume和Apache Solr使用的端口 Apache Flume用于与Apache Solr通信的端口可能会有所不同,具体取决于您的配置以及是否使用安全性(例如,SSL).使用Fl ...
- 1、CDH 搭建Hadoop在安装之前(存储空间规划)
Cloudera Manager的存储空间规划 最低要求角色: 完全管理员 Cloudera Manager跟踪许多后台进程中的服务,作业和应用程序的度量标准.所有这些指标都需要存储.根据组织的大小, ...
- msf客户端渗透(一):payload利用简单示范
针对Windows 开启侦听 查看payload选项 将1.exe传到网页上 win7访问网页并下载1.exe 下载好之后双击运行,在服务器端就获得了一个shell 针对linux 先获取到一个软 ...
- python中matplotlib 的简单使用
1.简单折线图的画图,轴标签.图的颜色,风格,等等参数,本文只介绍最常用的几个参数: import matplotlib.pyplot as plt import numpy as np x = np ...
- PAT1135(红黑书的判定)
There is a kind of balanced binary search tree named red-black tree in the data structure. It has th ...
- Lua的闭包详解(终于搞懂了)
词法定界:当一个函数内嵌套另一个函数的时候,内函数可以访问外部函数的局部变量,这种特征叫做词法定界 table.sort(names,functin (n1,n2) return grades[n1] ...
- [Java笔记]面向对象-单例模式
单例模式 目标 使JVM中最多只有一个该类的实例,以节省内存.缺点:只能建一个该类的实例. 实现 具体实现思路: 1构造方法私有化//故在外面不能new很多次 2对外提供一个公开的静态的类方法,获取类 ...
- IOS是否存在32位和64位版本的区分
苹果于2013年9月推出了iPhone 5S新手机,采用的全新A7处理器其最大特色就是支持64位运算.其64位A7处理器的使用意味着iPhone性能会大有提高,性能和速度更加出色:而要到达到这样的性能 ...