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这个利器. 先说遇到的问题: 网上也有教程,不过五花八门的,挨个尝试了一遍,也没有成功运行.最后终于找到问题所在: 从开发 ...
随机推荐
- ETL工具总结
ETL的考虑 做 数据仓库系统,ETL是关键的一环.说大了,ETL是数据整合解决方案,说小了,就是倒数据的工具.回忆一下工作这么些年来,处理数据迁移.转换的工作倒 还真的不少.但是那些工 ...
- php 指定页面显示所有报错
ini_set('display_errors',1); error_reporting(E_ALL);
- c 中的单引号和双引号的使用
1. 在c中,'A' 表示的是一个 character constant ,表示的是字符集的数值:而 "A" 表示的是一个字符串常量,代表的是指向字符串的指针.
- redis分布式锁Redisson扩展
如果大家项目中Redis是多机部署的可以来好好看看这篇实现,讲的非常好. 使用Redisson实现分布式锁,Spring AOP简化之 源码 Redisson概述 Redisson是一个在Redi ...
- 微信小程序商品筛选,侧方弹出动画选择页面
https://blog.csdn.net/qq_36538012/article/details/85110641
- 数据库类型空间效率探索(三)-char
测试环境 表信息 表数据量22.23万,占用空间44.494M 用到的sql语句 增加列:alter table t_type add column new_column char(1) defaul ...
- 关于RAID的概述
Raid 0:一块硬盘或者以上就可做raid0优势:数据读取写入最快,最大优势提高硬盘容量,比如3快80G的硬盘做raid0 可用总容量为240G.速度是一样.缺点:无冗余能力,一块硬盘损坏,数据全无 ...
- verilog之inout
1.inout 类型的data信号 写操作有效时(rd_wr_l=0):data端口输入信号,此时data为高阻态,允许对其进行赋值. 读操作有效时(rd_wr_l=1):data端口输出信号,此时d ...
- 两条线段求交点+叉积求面积 poj 1408
题目链接:https://vjudge.net/problem/POJ-1408 题目是叫我们求出所有四边形里最大的那个的面积. 思路:因为这里只给了我们正方形四条边上的点,所以我们要先计算横竖线段两 ...
- TOJ4757: 12345(数学)
传送门 时间限制(普通/Java):1000MS/3000MS 内存限制:65536KByte 描述 为了说明水题也不是那么好AC的,FD出了一个由数字1~5组成的题目,题意如下: 给定一个正 ...