我正在运行一个基于 Django 的网站以及 Linux、Apache 和 MySQL 系统。
在我的 settings.py
中,我有:
SITE_ID = int(os.environ.get("SITE_ID", 1))
我已经通过 Web 管理界面设置了正确的域名(然后保存),但当我重新启动 Apache 服务器时,它仍然设置回 localhost:8000
。
我一定错过了什么,但我不知 Prop 体是什么。如果有人确实遇到过这个问题并且知道解决方案,我会很高兴。
最佳答案
我发现出了什么问题(感谢 friend )。
事实上,在我的项目的根目录下有一个固定文件 fixtures/initial_data.json
,其中包含:
[
{
"pk": 1,
"model": "sites.site",
"fields": {
"domain": "localhost:8000",
"name": "MyProjectName"
}
},
{
"pk": 2,
"model": "sites.site",
"fields": {
"domain": "mydomain.net",
"name": "MyProjectName"
}
}
]
而且,每次我重新启动网络服务器时,固定装置都会安装在服务器上...因此,导致域名重置。
我只需通过 mydomain.net
更改 localhost:8000
即可,一切顺利。
关于python - Site.domain不断更改为localhost :8000 all the time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21866166/