我在这里非常绝望。我不明白为什么
Django
看不到环境变量,即使
shell
可以
在里面
设置.py
BASE_URL = os.getenv('VUE_APP_WEB_URL','http://127.0.0.1:8080/')
在里面
admin.py
class _UserAdmin...
...
list_display = ('username', 'email', 'is_staff', '_set_pwd_url','base_url')
list_filter = ('is_staff', 'is_superuser', 'is_active', 'groups')
def base_url(self, obj: User):
return settings.BASE_URL
在里面
/etc/环境
VUE_APP_WEB_URL=http://my.url.xyz/
服务器已多次重新启动,而且
Gunicorn
已由重新启动
sudo service gunicorn restart
它仍然显示默认值,而不是ENV VAR。
现在,当我在中测试时
django shell
:
Python 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> settings.BASE_URL
'http://my.url.xyz/'
>>>
发生了什么事?
附言:浏览器缓存不是问题所在。