Django 1.8,Heroku,Powershell。
我试图在Heroku中为我的django密钥设置环境变量:
(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.
我也尝试用斜杠转义,在整个字符串周围加上引号等。结果相同。那么如何设置我的环境变量呢?
答案 0 :(得分:1)
我不熟悉Heroku,但假设heroku
是可执行的而config:set SECRET_KEY=eo...
是命令行参数,你可以试试这个:
& 'heroku' @('config:set', 'SECRET_KEY=eoik6-"&"dnr9elgmrt7-%3hu_"&"37$3hg!9c6x!^khjr3!z*z"&"b4')
答案 1 :(得分:1)
我只是尝试了一些东西,当你在整个VALUE周围加上单引号(以及&符号周围的双引号)时它会起作用:
UPDATE
可通过命令SELECT