国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

djangoDEBUG=False

2019-11-14 17:09:09
字體:
來源:轉載
供稿:網友

在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.

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 朝阳市| 河曲县| 武清区| 宁都县| 永昌县| 清苑县| 西平县| 闻喜县| 洪泽县| 拉孜县| 湖南省| 崇礼县| 钟祥市| 什邡市| 无锡市| 阿坝县| 金川县| 密山市| 博客| 孟州市| 钟祥市| 陇南市| 洞头县| 宽甸| 青浦区| 潞西市| 田林县| 昂仁县| 贵州省| 陆河县| 白朗县| 保靖县| 芦山县| 达日县| 凤山市| 遵义县| 博客| 高雄市| 文水县| 柳江县| 屏东市|