Django 1.8、Heroku、Powershell。
我正在尝试为 Heroku 中的 django key 设置环境变量:
(venv) PS WORKFOLDER> heroku config:set SECRET_KEY=eoik6-&dnr9elgmrt7-%3hu_&37$3hg!9c6x!^khjr3!z*z&b4
我收到此错误消息(3 次 - 因为字符串中有 3 个&符号):
At line:1 char:77
+ heroku config:set SECRET_KEY=eoik6-&dnr9elgmrt7-%3hu_&37$3hg!9c6x!^khjr3!z*z&b4
+ ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double
quotation marks ("&") to pass it as part of a string.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : AmpersandNotAllowed
当我尝试建议的解决方案时(在 & 符号周围加上双引号):
(venv) PS WORKFOLDER> heroku config:set SECRET_KEY=eoik6-"&"dnr9elgmrt7-%3hu_"&"37$3hg!9c6x!^khjr3!z*z"&"b4
我收到此错误:
SECRET_KEY: eoik6-
'dnr9elgmrt7-%3hu_' is not recognized as an internal or external command, operable program or batch file.
'37$3hg!9c6x!^khjr3!z*z' is not recognized as an internal or external command, operable program or batch file.
'b4' is not recognized as an internal or external command, operable program or batch file.
我也尝试用斜杠转义,在整个字符串周围加上引号等。结果相同。那么如何设置我的环境变量呢?
最佳答案
我不熟悉 Heroku,但假设 heroku
是可执行的并且 config:set SECRET_KEY=eo...
是命令行参数,你可以试试这个:
& 'heroku' @('config:set', 'SECRET_KEY=eoik6-"&"dnr9elgmrt7-%3hu_"&"37$3hg!9c6x!^khjr3!z*z"&"b4')
关于django - 使用特殊字符在 Heroku(通过 powershell)中设置环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32130105/